diff --git a/lcl/include/customstatictext.inc b/lcl/include/customstatictext.inc index cb3c9bcb03..282012cdf2 100644 --- a/lcl/include/customstatictext.inc +++ b/lcl/include/customstatictext.inc @@ -135,7 +135,14 @@ begin begin FStaticBorderStyle := Value; if HandleAllocated then + begin TWSCustomStaticTextClass(WidgetsetClass).SetStaticBorderStyle(Self, Value); + if AutoSize then + begin + InvalidatePreferredSize; + AdjustSize; + end; + end; end; end; diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index b98add2c28..77852be1d7 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -208,6 +208,9 @@ type published class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override; + class procedure GetPreferredSize(const AWinControl: TWinControl; + var PreferredWidth, PreferredHeight: integer; + WithThemeSpace: Boolean); override; class procedure SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); override; class procedure SetStaticBorderStyle(const ACustomStaticText: TCustomStaticText; const NewBorderStyle: TStaticBorderStyle); override; class procedure SetText(const AWinControl: TWinControl; const AText: String); override; @@ -1329,6 +1332,29 @@ begin Result := Params.Window; end; +class procedure TWin32WSCustomStaticText.GetPreferredSize( + const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; + WithThemeSpace: Boolean); +begin + if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, PreferredHeight) then + begin + Inc(PreferredHeight); + if TCustomStaticText(AWinControl).BorderStyle <> sbsNone then + begin + if ThemeServices.ThemesEnabled and (TCustomStaticText(AWinControl).BorderStyle = sbsSingle) then + begin + inc(PreferredWidth, 4); + inc(PreferredHeight, 4); + end + else + begin + inc(PreferredWidth, 2); + inc(PreferredHeight, 2); + end; + end; + end; +end; + class procedure TWin32WSCustomStaticText.SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); begin if not WSCheckHandleAllocated(ACustomStaticText, 'SetAlignment') then