2
votes

Hi I am having delphi application which uses more than 100 forms. There is one form call Form B which derived from the Form A.

Unit B 

interace

uses A;

Type
Form B = Class(Form A)

End;

Now, when i try to open Form B on the IDE i m getting the error, "Error cerating form: Ancestor for TFormA not found". But when i open Form A and then try to form B then i am able to open form without any error. I am not able to find why its happening. Am i missed something?

3
Did you use IDE to inherit FormB from FormA, or just did it manually?kludg
SO you are using form inheritance. Two items to keep in mind. The dfm file needs to have the declaration "inherited TFormB" instead of "object TFormB" The other item is Delphi needs to know where TFormA is located before it can create TFormB. It's been a while since I have done this and if I remember correctly, it works better when the base form has been added to the repository.GDF
@serg: no just did it manually.Nalu
@GDF: yes i am using the inheritanceNalu
Since you point out you did it manually, make sure you open both forms. Then view TFormB as text, and change it to inherited like I described in my first comment. Gonna wrap the 2 comments into an answer postGDF

3 Answers

2
votes

Two items to keep in mind when using form inheritance. The dfm file needs to have the declaration "inherited TFormB" instead of "object TFormB" The other item is Delphi needs to know where TFormA is located before it can create TFormB. It's been a while since I have done this and if I remember correctly, it works better when the base form has been added to the repository

Since you point out you did it manually make sure that the declaration in the dfm is using the word "inherited" instead of "object" as I described above. To make the change yourself do the following

1) open both forms. 2) Then view TFormB as text 3) Change it to inherited like described below

    inherited FormB: TFormB
      Caption = 'FormB'
      PixelsPerInch = 96
      TextHeight = 13
    end

// not

    object FormB: TFormB
      Caption = 'FormB'
      PixelsPerInch = 96
      TextHeight = 13
    end
1
votes

You should use visual form inheritance provided by Delphi IDE; I have no Delphi 5, in Delphi XE it is accessed by File->New->Other...->Inheritable Items. I am sure it is available in Delphi 5 too, but probably from a different menu item

0
votes

I had the same problem despite everything being "inherited" in the DFM file.

What fixed my problem was adding the ancestor file to the project by right-clicking in the project manager -> add and selecting the ancestor file.