diff --git a/lcl/forms.pp b/lcl/forms.pp index e0b21179e8..2a520ae074 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -137,6 +137,7 @@ type property Kind: TScrollBarKind read FKind; function GetOtherScrollBar: TControlScrollBar; property Size: integer read GetSize write SetSize stored False; + function ClientSize: integer; // return for vertical scrollbar the clientwidth function ClientSizeWithBar: integer; // return for vertical scrollbar the clientwidth with the bar, even if Visible=false function ClientSizeWithoutBar: integer; // return for vertical scrollbar the clientwidth without the bar, even if Visible=true published diff --git a/lcl/include/buttons.inc b/lcl/include/buttons.inc index d7b1699a67..15acb43af0 100644 --- a/lcl/include/buttons.inc +++ b/lcl/include/buttons.inc @@ -287,7 +287,7 @@ begin end; end; inherited WSSetText(AText); - //DebugLn(['TCustomButton.WSSetText ',dbgsName(Self),' Caption="',Caption,'" AutoSizeCanStart=',AutoSizeCanStart,' AutoSizeDelayed=',AutoSizeDelayed]); + //DebugLn(['TCustomButton.WSSetText ',dbgsName(Self),' Caption="',Caption,'"]); end; procedure TCustomButton.TextChanged; diff --git a/lcl/include/controlscrollbar.inc b/lcl/include/controlscrollbar.inc index 395f62c62e..9872f34e1f 100644 --- a/lcl/include/controlscrollbar.inc +++ b/lcl/include/controlscrollbar.inc @@ -490,22 +490,24 @@ begin Result := GetVertSCrollbar; end; -function TControlScrollBar.ClientSizeWithBar: integer; +function TControlScrollBar.ClientSize: integer; begin if Kind = sbVertical then Result:=FControl.ClientWidth else Result:=FControl.ClientHeight; +end; + +function TControlScrollBar.ClientSizeWithBar: integer; +begin + Result:=ClientSize; if not Visible then dec(Result,GetSize); end; function TControlScrollBar.ClientSizeWithoutBar: integer; begin - if Kind = sbVertical then - Result:=FControl.ClientWidth - else - Result:=FControl.ClientHeight; + Result:=ClientSize; if Visible then inc(Result,GetSize); end; diff --git a/lcl/include/scrollingwincontrol.inc b/lcl/include/scrollingwincontrol.inc index c0e1b5e19e..a700d6b599 100644 --- a/lcl/include/scrollingwincontrol.inc +++ b/lcl/include/scrollingwincontrol.inc @@ -121,14 +121,7 @@ function TScrollingWinControl.ComputeScrollbars: Boolean; OldAutoRange := p_Bar.FAutoRange; p_Bar.FAutoRange := 0; OtherScrollbar := p_Bar.GetOtherScrollBar; - if OtherScrollbar.FVisible then - SBSize := OtherScrollbar.Size - else - SBSize := 0; - if p_Bar.Kind = sbVertical then - SBSize := ClientHeight - SBSize - else - SBSize := ClientWidth - SBSize; + SBSize := OtherScrollbar.ClientSize; if (p_Bar.FRange > SBSize) and (SBSize > 0) then p_Bar.FAutoRange := (p_Bar.FRange - SBSize) else @@ -145,14 +138,15 @@ var NewPage: Integer; begin Result := False; - // page - NewPage := Max(1,Min(ClientWidth - 1, High(HorzScrollbar.FPage))); + + // page (must be smaller than Range and at least 1) + NewPage := Max(1,Min(VertScrollbar.ClientSize - 1, High(HorzScrollbar.FPage))); if NewPage <> HorzScrollbar.FPage then begin HorzScrollbar.FPage := NewPage; Result := True; end; - NewPage := Max(1,Min(ClientHeight - 1, High(VertScrollbar.FPage))); + NewPage := Max(1,Min(HorzScrollbar.ClientSize - 1, High(VertScrollbar.FPage))); if NewPage <> VertScrollbar.FPage then begin VertScrollbar.FPage := NewPage; diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 116e57a377..7a913f4538 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -3292,7 +3292,7 @@ begin {$ENDIF} if not (caspComputingBounds in AutoSizePhases) then begin {$IFDEF VerboseAllAutoSize} - DebugLn(['TWinControl.DoAutoSize DELAYED AutoSizeCanStart=',AutoSizeCanStart,' AutoSizeDelayed=',AutoSizeDelayed,' AutoSizePhase=',AutoSizePhaseNames[AutoSizePhase]]); + DebugLn(['TWinControl.DoAutoSize DELAYED AutoSizePhase=',AutoSizePhaseNames[AutoSizePhase]]); {$ENDIF} Include(FControlFlags,cfAutoSizeNeeded); exit;