diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index c9e32b1432..caa896a497 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -7797,7 +7797,17 @@ begin inc(PreferredHeight,BorderSpacing.InnerBorder*2); end; + // check AdjustClientRect + CurClientRect:=Rect(0,0,1000,1000); + AdjustedClientRect:=CurClientRect; + AdjustClientRect(AdjustedClientRect); + PreferredWidth:=Max(PreferredWidth, + AdjustedClientRect.Left+CurClientRect.Right-AdjustedClientRect.Right); + PreferredHeight:=Max(PreferredHeight, + AdjustedClientRect.Top+CurClientRect.Bottom-AdjustedClientRect.Bottom); + if ControlCount>0 then begin + // Beware: ControlCount>0 does not mean that there are visible childs // get the size requirements for the child controls Layout:=nil; @@ -7824,15 +7834,6 @@ begin {$ENDIF} PreferredWidth:=Max(PreferredWidth,NewWidth); PreferredHeight:=Max(PreferredHeight,NewHeight); - end else begin - // check AdjustClientRect - CurClientRect:=Rect(0,0,1000,1000); - AdjustedClientRect:=CurClientRect; - AdjustClientRect(AdjustedClientRect); - PreferredWidth:=Max(PreferredWidth, - AdjustedClientRect.Left+CurClientRect.Right-AdjustedClientRect.Right); - PreferredHeight:=Max(PreferredHeight, - AdjustedClientRect.Top+CurClientRect.Bottom-AdjustedClientRect.Bottom); end; {$IFDEF VerboseAutoSize} debugln('TWinControl.CalculatePreferredSize ',DbgSName(Self),