diff --git a/lcl/interfaces/carbon/carbonedits.pp b/lcl/interfaces/carbon/carbonedits.pp index bdfae94d1d..ad83aa8b3f 100644 --- a/lcl/interfaces/carbon/carbonedits.pp +++ b/lcl/interfaces/carbon/carbonedits.pp @@ -186,6 +186,7 @@ type procedure SetScrollBars(const AValue: TScrollStyle); protected function GetFrame({%H-}Index: Integer): ControlRef; override; + function GetPreferredSize: TPoint; override; procedure CreateWidget(const AParams: TCreateParams); override; procedure DestroyWidget; override; procedure GetLineOffset(AIndex: Integer; out AStart, AEnd: TXNOffset); @@ -1526,6 +1527,11 @@ begin Result:=FBorder; end; +function TCarbonMemo.GetPreferredSize: TPoint; +begin + Result.X:=0; + Result.Y:=0; +end; {------------------------------------------------------------------------------ Method: TCarbonMemo.CreateWidget diff --git a/lcl/interfaces/carbon/carbonprivatecontrol.inc b/lcl/interfaces/carbon/carbonprivatecontrol.inc index 39d639e578..3d780c5e9f 100644 --- a/lcl/interfaces/carbon/carbonprivatecontrol.inc +++ b/lcl/interfaces/carbon/carbonprivatecontrol.inc @@ -1747,7 +1747,7 @@ end; {------------------------------------------------------------------------------ Method: TCarbonControl.GetPreferredSize - Returns: The preffered size of control for autosizing or (0, 0) + Returns: The prefered size of control for autosizing or (0, 0) ------------------------------------------------------------------------------} function TCarbonControl.GetPreferredSize: TPoint; var @@ -1757,12 +1757,17 @@ begin Result.X := 0; Result.Y := 0; - R := GetCarbonRect(0, 0, 0, 0); - - if OSError(GetBestControlRect(ControlRef(Widget), R, S{%H-}), Self, - 'GetPreferredSize', 'GetBestControlRect') then Exit; + if (LCLObject is TWinControl) and (TWinControl(LCLObject).ControlCount>0) then + begin - Result.X := R.right - R.left; - Result.Y := R.bottom - R.top; + end else begin + R := GetCarbonRect(0, 0, 0, 0); + + if OSError(GetBestControlRect(ControlRef(Widget), R, S{%H-}), Self, + 'GetPreferredSize', 'GetBestControlRect') then Exit; + + Result.X := R.right - R.left; + Result.Y := R.bottom - R.top; + end; end;