Reputation: 1117
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?
Upvotes: 2
Views: 4653
Reputation: 507
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.
Upvotes: 0
Reputation: 860
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
Upvotes: 2
Reputation: 27493
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
Upvotes: 1