procedure TCustomForm.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
case Operation of
opInsert:
begin
if AComponent is TCustomActionList then
begin
if FActionLists = nil then FActionLists := TList.Create;
FActionLists.Add(AComponent);
end
else if not (csLoading in ComponentState) and (Menu = nil) and
(AComponent.Owner = Self) and (AComponent is TMainMenu) then
Menu := TMainMenu(AComponent);
end;
opRemove:
begin
if (FActionLists <> nil) and (AComponent is TCustomActionList) then
FActionLists.Remove(AComponent)
else
begin
if Menu = AComponent then Menu := nil;
if WindowMenu = AComponent then WindowMenu := nil;
if ObjectMenuItem = AComponent then ObjectMenuItem := nil;
end;
end;
end;
if FDesigner <> nil then
FDesigner.Notification(AComponent, Operation);
end;
这是来自vcl的代码。