If you want a component (TMyComponent) to be notified about another
component being freed, eg. when one of its sub-components
(TMySubComponent) is removed, call
TMySubComponent.FreeNotification(TMyComponent) at some point, usually
during TMySubComponent's construction.  Then TMyComponent gets an
OpRemove notification just before TMySubComponent is freed.  That's
without using InsertComponent or RemoveComponent - is that what you
meant?

If you want to let other components on a form know of a component's
impending demise, and those other components haven't been given
FreeNotification from the component, then the form has to do the work
(iterating through its components list to let the appropriate components
know as required).  Hope that helps...

Cheers,

Carl Reynolds                      Ph: +64-9-4154790
CJN Technologies Ltd.             Fax: +64-9-4154791
[EMAIL PROTECTED]                DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/

> -----Original Message-----
> From: Myles Penlington [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, July 06, 1999 11:53 AM
> To:   Multiple recipients of list delphi
> Subject:      [DUG]:  Notification Bug on Remove???
> 
> What's your understanding of the Delphi Notification mechanism??
> 
> My understanding is that if a TComponent or its descendant is removed
> from a Form then all other components on the Form will be sent a
> Notification (  MyComponent, OpRemove) - of course its owner is the
> form - this all stuff in the DFM.
> 
> However this appears to be NOT the case. No OpRemove notification sent
> is if the component being removed is descended from TComponent eg
> TQuery etc - It does work if you remove a TControl or TWinControl.
> 
> e.g. If you put a TButton , TDatabase and a TQuery on a form (in that
> order), the TDatabase does not get notified of the destruction of the
> TQuery - not that it matters in this case (but we have other cases
> that do matter - our own components).
> 
> The offending code is in TComponent. 
> 
> procedure TComponent.DestroyComponents; // This is called from
> TComponent.Destroy 
> var
>   Instance: TComponent;
> begin
>   while FComponents <> nil do
>   begin
>     Instance := FComponents.Last;
>     Remove(Instance); // IF THIS WAS RemoveComponent then all would be
> okay, or if TComponent.Remove did not set the owner to NIL.
>     Instance.Destroy;
>   end;
> end;
> 
> Do I have my understanding wrong or is this a serious bug/stuff up??
> Can someone (Richard/Nic?) explain why it has been done this way??
> By the way all the components do get a Notification( , OpInsert), when
> they are created from the DFM, they just do not get the OpRemove when
> the form is destroyed, this occurs as TComponent.Create does a
> InsertComponent which does do a notification.
> 
> Comments Please.
> 
> Regards
> 
> Myles Penlington
> ADVANCED MANAGEMENT SYSTEMS
> 
> ----------------------------------------------------------------------
> -----
>     New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz

application/ms-tnef

Reply via email to