procedure TControl.SetParent(AParent: TWinControl);
begin
if FParent <> AParent then
begin
if AParent = Self then
raise EInvalidOperation.CreateRes(@SControlParentSetToSelf);
if FParent <> nil then
FParent.RemoveControl(Self);
if AParent <> nil then
begin
AParent.InsertControl(Self);
UpdateAnchorRules;
end;
end;
end;
procedure TWinControl.InsertControl(AControl: TControl);
begin
AControl.ValidateContainer(Self);
Perform(CM_CONTROLLISTCHANGE, Integer(AControl), Integer(True));
Insert(AControl);
if not (csReading in AControl.ComponentState) then
begin
AControl.Perform(CM_PARENTCOLORCHANGED, 0, 0);
AControl.Perform(CM_PARENTFONTCHANGED, 0, 0);
AControl.Perform(CM_PARENTSHOWHINTCHANGED, 0, 0);
AControl.Perform(CM_PARENTBIDIMODECHANGED, 0, 0);
if AControl is TWinControl then
begin
AControl.Perform(CM_PARENTCTL3DCHANGED, 0, 0);
UpdateControlState;
end else
if HandleAllocated then AControl.Invalidate;
AlignControl(AControl);
end;
Perform(CM_CONTROLCHANGE, Integer(AControl), Integer(True));
end;