Board index » delphi » changing inheritance of forms

changing inheritance of forms

Hi,

I decided to change the inheritance of my existing forms:

FROM: TMyFirstForm = class(TForm)
TO:   TMyFirstForm = class(TMyBaseForm)

But, I think this screws up delphi. The codebrowser has trouble finding the
parent form (TMyBaseForm), and sometime's an internal compiler error pops
up.

Do I need to change the .dfm files of my forms?

Regards,
Erwin

 

Re:changing inheritance of forms


You can do this, but this is the safest way:

1. Open up the form you want to change.
2. Edit the form source for your new ancestor.
3. Make sure that the new ancestor is referenced in the interface "uses"
clause.
4. Save the form.
5. CLOSE THE FORM <--- vital step
6. Reopen the form. All should now be OK.

When you first open the form, Delphi starts to maintain a lot of information
about it, including "hot-links" to it's ancestors. If you change the
ancestor
while this is happening, you will confuse it. Closing the form the minute
you change the ancestor declaration should not affect this internal state,
which is flushed and refreshed when you open the form again.

----
Philip Brown
Informatica Systems Ltd

Quote
"Erwin Molendijk" <e.j.molend...@student.utwente.nl> wrote in message

news:3b3c59aa_2@dnews...
Quote
> Hi,

> I decided to change the inheritance of my existing forms:

> FROM: TMyFirstForm = class(TForm)
> TO:   TMyFirstForm = class(TMyBaseForm)

> But, I think this screws up delphi. The codebrowser has trouble finding
the
> parent form (TMyBaseForm), and sometime's an internal compiler error pops
> up.

> Do I need to change the .dfm files of my forms?

> Regards,
> Erwin

Re:changing inheritance of forms


Quote
In article <3b3c59aa_2@dnews>, Erwin Molendijk wrote:
> I decided to change the inheritance of my existing forms:

> FROM: TMyFirstForm = class(TForm)
> TO:   TMyFirstForm = class(TMyBaseForm)

> But, I think this screws up delphi. The codebrowser has trouble finding the
> parent form (TMyBaseForm), and sometime's an internal compiler error pops
> up.

> Do I need to change the .dfm files of my forms?

Yes. If you look at a standard form in text view mode you see that it starts
with

object Form1: TForm1
..

If you look at a form based on an ancestor form the DFM starts with

inherited Form1: TForm1

You have to do this in the correct sequence. First change the form
declaration in the unit, then switch to the form (F12), switch to the "view
as text" mode, change the DFM. The switch back to the form view.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Re:changing inheritance of forms


"Peter Below (TeamB)" <100113.1...@compuXXserve.com> wrote:

Quote
> In article <3b3c59aa_2@dnews>, Erwin Molendijk wrote:
> > I decided to change the inheritance of my existing forms:

> > FROM: TMyFirstForm = class(TForm)
> > TO:   TMyFirstForm = class(TMyBaseForm)

> > But, I think this screws up delphi. The codebrowser has trouble finding
the
> > parent form (TMyBaseForm), and sometime's an internal compiler error
pops
> > up.

> > Do I need to change the .dfm files of my forms?

> Yes. If you look at a standard form in text view mode you see that it
starts
> with

> object Form1: TForm1
> ..

> If you look at a form based on an ancestor form the DFM starts with

> inherited Form1: TForm1

> You have to do this in the correct sequence. First change the form
> declaration in the unit, then switch to the form (F12), switch to the
"view
> as text" mode, change the DFM. The switch back to the form view.

Thanks, but I had allready used the wrong sequence. Because the codebrowser
still didn't work.

The solution after a few hours of testing:
1. Change first word in inherited .dfm files: "object" into "inherited"
2. delete file: .res
3. delete file: .dof
4. delete file: .dsk
5. start delphi, it recreates the deleted files and gives a warning
6. fill in the compiler settings (which have been lost ofcourse)
7. rebuild project
8. restart delphi

Now the codebrowser is working again, and no more internal compiler errors.
Maybe not all steps are needed, but it (finally) works.

Regards,
Erwin

Other Threads