Board index » delphi » Ancestor for ... not found

Ancestor for ... not found

This seems to be my day for getting into difficulties.

I have an MDI project where I have a parent form and two types of child
form.  The child forms were originally form-inherited (best I recall)
from a form (MDIChild) that provided some common functionality.

At one point, I decided that I wanted to inherit all the code
functionality from TMDIChild, but didn't care about inheriting the
appearance.  In fact, I specifically didn't want to inherit any of the
DFM's characteristics, since this included a WindowStyle of fsMDIChild,
and I wanted to inherit TMDIChild's functionality for my main form.

So I took out the {$R *.DFM} line from the TMDIChild code, and had
everything else do regular class inheritance from it:  TMainForm =
class(TMDIChild), etc.

At this point, the main form will display, but none of the child forms
display when I create them in code.  Likewise, they won't display from
the IDE: I get 'Ancestor for TMDIChild not found...' when I try to
display them.

I figured there was some dependency in their dfms on TMDIChild's dfm,
but when I restored it, and restored the {$R *.DFM} line to TMDIChild,
the problem didn't go away.  
If someone could explain to me what is happening here, I would
appreciate it.  At this point, the main thing is to just get things
working again, even if I have to give up on my common inheritance for my
main and child forms.

TIA.

 

Re:Ancestor for ... not found


Whew!  Got everything working.  Had to remove all the forms from my
project and put them back again.  At that point I could display the dfms
as text and change the 'inherited' keyword to 'object', to turn off form
inheritance from MDIChild.  (I suspect that the problem was that for
some reason the IDE didn't know that MDIChild's dfm, and the reference
to it, were back; I maybe could have just taken it out and put it back
again).  Now that I was just using regular old inheritance, got rid of
the {$R *.DFM} line (again) from the MDIChild form.  Now I could inherit
its methods just fine from all my other forms, including the main MDI
form.

In case anyone was wondering...  :-)

Quote
Keith G. Murphy wrote:

> This seems to be my day for getting into difficulties.

> I have an MDI project where I have a parent form and two types of child
> form.  The child forms were originally form-inherited (best I recall)
> from a form (MDIChild) that provided some common functionality.

> At one point, I decided that I wanted to inherit all the code
> functionality from TMDIChild, but didn't care about inheriting the
> appearance.  In fact, I specifically didn't want to inherit any of the
> DFM's characteristics, since this included a WindowStyle of fsMDIChild,
> and I wanted to inherit TMDIChild's functionality for my main form.

> So I took out the {$R *.DFM} line from the TMDIChild code, and had
> everything else do regular class inheritance from it:  TMainForm =
> class(TMDIChild), etc.

> At this point, the main form will display, but none of the child forms
> display when I create them in code.  Likewise, they won't display from
> the IDE: I get 'Ancestor for TMDIChild not found...' when I try to
> display them.

> I figured there was some dependency in their dfms on TMDIChild's dfm,
> but when I restored it, and restored the {$R *.DFM} line to TMDIChild,
> the problem didn't go away.
> If someone could explain to me what is happening here, I would
> appreciate it.  At this point, the main thing is to just get things
> working again, even if I have to give up on my common inheritance for my
> main and child forms.

> TIA.

Other Threads