From 4891f1f0e1aebe5903daeff49bd6360b34e09eea Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 11 Oct 2023 19:53:19 +0200 Subject: [PATCH] TScrollBox: fix flicker when Form.AutoSizeAll is called. Do not call ShowScrollBar when nothing changed. --- lcl/forms.pp | 1 + lcl/include/controlscrollbar.inc | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lcl/forms.pp b/lcl/forms.pp index 984b27eed0..e64251a7ad 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -107,6 +107,7 @@ type FTracking: Boolean; FVisible: Boolean; FOldScrollInfo: TScrollInfo; + FOldVisible: Boolean; FOldScrollInfoValid: Boolean; protected FControl: TWinControl; diff --git a/lcl/include/controlscrollbar.inc b/lcl/include/controlscrollbar.inc index 4de12c29fb..29917ddc36 100644 --- a/lcl/include/controlscrollbar.inc +++ b/lcl/include/controlscrollbar.inc @@ -230,14 +230,18 @@ begin if (not FOldScrollInfoValid) or (not CompareMem(@ScrollInfo, @FOldScrollInfo, SizeOf(TScrollInfo))) then begin FOldScrollInfo := ScrollInfo; - FOldScrollInfoValid := True; SetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo, NewVisible); // update policy too ScrollInfo.fMask := SIF_UPDATEPOLICY; ScrollInfo.nTrackPos := TrackToPolicyMap[FTracking]; SetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo, NewVisible); - end; - ShowScrollBar(ControlHandle, IntfBarKind[Kind], NewVisible); + ShowScrollBar(ControlHandle, IntfBarKind[Kind], NewVisible); + end + else + if (not FOldScrollInfoValid) or (FOldVisible <> NewVisible) then + ShowScrollBar(ControlHandle, IntfBarKind[Kind], NewVisible); + FOldVisible := NewVisible; + FOldScrollInfoValid := True; {$IFDEF VerboseScrollingWinControl} //if DebugCondition then DebugLn(['TControlScrollBar.UpdateScrollBar ',DbgSName(FControl),' ',DbgSName(Self),' ',dbgs(Kind),' FVisible=',FVisible,' Range=',FRange,' FPosition=',FPosition,' FPage=',FPage,' FAutoRange=',FAutoRange,' ShouldVisible=',NewVisible,' IsVisible=',IsScrollBarVisible]);