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