From 1df9cbaea52314a40159c0891a17a8ce959ec7e0 Mon Sep 17 00:00:00 2001 From: lazarus Date: Sun, 27 Oct 2002 23:24:19 +0000 Subject: [PATCH] MG: reduced messages of TScrollingWinControl git-svn-id: trunk@3576 - --- lcl/forms.pp | 4 --- lcl/include/scrollingwincontrol.inc | 39 +++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lcl/forms.pp b/lcl/forms.pp index 92f7d8956f..959ee73a66 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -88,13 +88,9 @@ type procedure ScrollHandler(var Message: TLMScroll); public constructor Create(AControl: TScrollingWinControl; AKind: TScrollBarKind); - procedure Assign(Source: TPersistent); override; - function IsScrollBarVisible: Boolean; - function ScrollPos: Integer; - property Kind: TScrollBarKind read FKind; published property Increment: TScrollBarInc read FIncrement write FIncrement default 8; diff --git a/lcl/include/scrollingwincontrol.inc b/lcl/include/scrollingwincontrol.inc index 6f8449a15e..06a30c64ea 100644 --- a/lcl/include/scrollingwincontrol.inc +++ b/lcl/include/scrollingwincontrol.inc @@ -22,7 +22,8 @@ procedure TControlScrollBar.SetPosition(Value: Integer); Tmp := FPosition; FPosition := Value; FControl.ScrollBy(0, Tmp - FPosition); - if GetScrollPos(FControl.Handle, SB_VERT) <> FPosition then + if FControl.HandleAllocated + and (GetScrollPos(FControl.Handle, SB_VERT) <> FPosition) then SetScrollPos(FControl.Handle, SB_VERT, FPosition, Visible); end; @@ -33,7 +34,8 @@ procedure TControlScrollBar.SetPosition(Value: Integer); Tmp := FPosition; FPosition := Value; FControl.ScrollBy(Tmp - FPosition, 0); - if GetScrollPos(FControl.Handle, SB_HORZ) <> FPosition then + if FControl.HandleAllocated + and (GetScrollPos(FControl.Handle, SB_HORZ) <> FPosition) then SetScrollPos(FControl.Handle, SB_HORZ, FPosition, Visible); end; @@ -52,6 +54,13 @@ begin exit; end; end; + + if Value>Range then begin + SetPosition(Range); + exit; + end; + + if Value=FPosition then exit; if Kind = sbVertical then SetVPosition @@ -66,18 +75,21 @@ begin Range := 0; exit; end; + if FRange=Value then exit; FRange := Value; FControl.UpdateScrollBars; end; procedure TControlScrollBar.SetVisible(Value: Boolean); begin + if FVisible = Value then exit; FVisible := Value; FControl.UpdateScrollBars; end; procedure TControlScrollBar.SetSmooth(Value: Boolean); begin + if FSmooth = Value then exit; FSmooth := Value; FControl.UpdateScrollBars; end; @@ -136,7 +148,7 @@ var procedure UpdateVScroll; begin With FControl do begin - Page := ClientHeight + 1; + Page := Min(ClientHeight + 1,High(Page)); ScrollInfo.nPage := Page; if Visible then begin @@ -146,20 +158,21 @@ var else ScrollInfo.nMax := 0; - If (Self.Visible and not FAutoScroll) or (FAutoScroll and (ScrollInfo.nMax > 0) and - (ScrollInfo.nMax > Height)) + If (Self.Visible and not FAutoScroll) + or (FAutoScroll and (ScrollInfo.nMax > 0) and (ScrollInfo.nMax > Height)) then Self.FVisible := True else Self.FVisible := False; - SetScrollInfo(Handle, SB_VERT, ScrollInfo, Self.Visible); + if HandleAllocated then + SetScrollInfo(Handle, SB_VERT, ScrollInfo, Self.Visible); end; end; procedure UpdateHScroll; begin With FControl do begin - Page := ClientWidth + 1; + Page := Min(ClientWidth + 1,High(Page)); ScrollInfo.nPage := Page; if Visible then begin @@ -169,13 +182,14 @@ var else ScrollInfo.nMax := 0; - If (Self.Visible and not FAutoScroll) or (FAutoScroll and (ScrollInfo.nMax > 0) and - (ScrollInfo.nMax > Width)) + If (Self.Visible and not FAutoScroll) + or (FAutoScroll and (ScrollInfo.nMax > 0) and (ScrollInfo.nMax > Width)) then Self.FVisible := True else Self.FVisible := False; - SetScrollInfo(Handle, SB_HORZ, ScrollInfo, Self.Visible); + if HandleAllocated then + SetScrollInfo(Handle, SB_HORZ, ScrollInfo, Self.Visible); end; end; @@ -269,7 +283,10 @@ end; function TControlScrollBar.ScrollPos: Integer; begin - Result := Position*ShortInt(Visible); + if Visible then + Result:=Position + else + Result:=0; end; procedure TScrollingWinControl.SetAutoScroll(Value: Boolean);