From be89c477d9d872e5d60ea6010bc6a65b69f182ad Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 13 Feb 2025 01:49:57 +0100 Subject: [PATCH] LCL: fix TControlScrollBar needs update if owner's handle changes. Issue #40794 introduced in 4891f1f0e1aebe5903daeff49bd6360b34e09eea --- lcl/forms.pp | 1 + lcl/include/custommemo.inc | 2 ++ lcl/include/scrollingwincontrol.inc | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lcl/forms.pp b/lcl/forms.pp index 8da2a35dbc..cafc46077d 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -180,6 +180,7 @@ type function AutoScrollEnabled: Boolean; virtual; procedure CalculateAutoRanges; virtual; procedure CreateWnd; override; + procedure DestroyWnd; override; function GetClientScrollOffset: TPoint; override; function GetLogicalClientRect: TRect; override;// logical size of client area procedure DoOnResize; override; diff --git a/lcl/include/custommemo.inc b/lcl/include/custommemo.inc index f967663c7a..f8b65162db 100644 --- a/lcl/include/custommemo.inc +++ b/lcl/include/custommemo.inc @@ -142,6 +142,8 @@ begin DebugLn('[TCustomMemo.FinalizeWnd] END ',DbgSName(Self),' ',FLines.ClassName,' FLines.Count=',dbgs(FLines.Count)); {$endif} end; + if FHorzScrollBar <> nil then FHorzScrollBar.InvalidateScrollInfo; + if FVertScrollBar <> nil then FVertScrollBar.InvalidateScrollInfo; inherited FinalizeWnd; end; diff --git a/lcl/include/scrollingwincontrol.inc b/lcl/include/scrollingwincontrol.inc index fd62d5c128..3461d7f07a 100644 --- a/lcl/include/scrollingwincontrol.inc +++ b/lcl/include/scrollingwincontrol.inc @@ -35,6 +35,13 @@ begin end; end; +procedure TScrollingWinControl.DestroyWnd; +begin + inherited DestroyWnd; + if FHorzScrollBar <> nil then FHorzScrollBar.InvalidateScrollInfo; + if FVertScrollBar <> nil then FVertScrollBar.InvalidateScrollInfo; +end; + function TScrollingWinControl.GetClientScrollOffset: TPoint; begin if (HorzScrollBar <> nil) and (VertScrollBar <> nil) then @@ -75,8 +82,7 @@ begin //debugln(['TScrollingWinControl.DoOnResize ',DbgSName(Self),' ',dbgs(BoundsRect),' ',dbgs(ClientRect),' ',dbgs(GetLogicalClientRect)]); end; -procedure TScrollingWinControl.GetPreferredSizeClientFrame(out aWidth, - aHeight: integer); +procedure TScrollingWinControl.GetPreferredSizeClientFrame(out aWidth, aHeight: Integer); // return frame width independent of scrollbars (i.e. as if scrollbars not shown) begin if AutoScroll and (VertScrollBar<>nil) then