procedure TWinControl.Loaded;
var
CachedText: string;
i: Integer;
AChild: TControl;
LoadedClientSize: TSize;
CurControl: TWinControl;
begin
//DebugLn(['TWinControl.Loaded START ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF};
try
//DebugLn(['TWinControl.Loaded ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);
if cfClientWidthLoaded in FControlFlags then
LoadedClientSize.cx:=FLoadedClientSize.cx
else begin
CurControl:=Self;
while CurControl<>nil do begin
LoadedClientSize.cx:=CurControl.ClientWidth;
if LoadedClientSize.cx>0 then break;
LoadedClientSize.cx:=CurControl.Width;
if LoadedClientSize.cx>0 then break;
CurControl:=CurControl.Parent;
end;
end;
if cfClientHeightLoaded in FControlFlags then
LoadedClientSize.cy:=FLoadedClientSize.cy
else begin
CurControl:=Self;
while CurControl<>nil do begin
LoadedClientSize.cy:=CurControl.ClientHeight;
if LoadedClientSize.cy>0 then break;
LoadedClientSize.cy:=CurControl.Height;
if LoadedClientSize.cy>0 then break;
CurControl:=CurControl.Parent;
end;
end;
for i:=0 to ControlCount-1 do begin
AChild:=Controls[i];
if AChild=nil then ;
AChild.FBaseParentClientSize:=LoadedClientSize;
//DebugLn(['TWinControl.Loaded Self=',DbgSName(Self),' AChild=',AChild,' AChild.FBaseParentClientSize=',dbgs(AChild.FBaseParentClientSize)]);
end;
if HandleAllocated then
begin
// Set cached caption
if GetCachedText(CachedText) then
WSSetText(CachedText);
InvalidatePreferredSize;
if wcfColorChanged in FWinControlFlags then
begin
TWSWinControlClass(WidgetSetClass).SetColor(Self);
NotifyControls(CM_PARENTCOLORCHANGED);
Exclude(FWinControlFlags, wcfColorChanged);
end;
if wcfFontChanged in FWinControlFlags then
begin
TWSWinControlClass(WidgetSetClass).SetFont(Self,Font);
NotifyControls(CM_PARENTFONTCHANGED);
FWinControlFlags:=FWinControlFlags-[wcfFontChanged];
end;
end;
inherited Loaded;
FixupTabList;
finally
//DebugLn(['TWinControl.Loaded enableautosizing ',DbgSName(Self),' ',dbgs(BoundsRect)]);
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF};
//DebugLn(['TWinControl.Loaded END ',DbgSName(Self),' ',dbgs(BoundsRect)]);
end;
end;