mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 07:38:14 +02:00
lcl: save/restore TControlScrollBar.Position even if AutoScroll = True (issue #0017409)
git-svn-id: trunk@30220 -
This commit is contained in:
parent
b8276754f7
commit
5e397ae583
@ -86,7 +86,7 @@ type
|
||||
|
||||
TControlScrollBar = class(TPersistent)
|
||||
private
|
||||
FAutoRange : Longint; // = FRange - ClientSize, >=0
|
||||
FAutoRange: Longint; // = FRange - ClientSize, >=0
|
||||
FIncrement: TScrollBarInc;
|
||||
FKind: TScrollBarKind;
|
||||
FPage: TScrollBarInc;
|
||||
@ -162,7 +162,6 @@ type
|
||||
FIsUpdating: Boolean;
|
||||
procedure SetHorzScrollBar(Value: TControlScrollBar);
|
||||
procedure SetVertScrollBar(Value: TControlScrollBar);
|
||||
function StoreScrollBars: Boolean;
|
||||
protected
|
||||
class procedure WSRegisterClass; override;
|
||||
procedure AlignControls(AControl: TControl; var ARect: TRect); override;
|
||||
@ -186,10 +185,8 @@ type
|
||||
class function GetControlClassDefaultSize: TSize; override;
|
||||
procedure ScrollBy(DeltaX, DeltaY: Integer); override;
|
||||
published
|
||||
property HorzScrollBar: TControlScrollBar
|
||||
read FHorzScrollBar write SetHorzScrollBar stored StoreScrollBars;
|
||||
property VertScrollBar: TControlScrollBar
|
||||
read FVertScrollBar write SetVertScrollBar stored StoreScrollBars;
|
||||
property HorzScrollBar: TControlScrollBar read FHorzScrollBar write SetHorzScrollBar;
|
||||
property VertScrollBar: TControlScrollBar read FVertScrollBar write SetVertScrollBar;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -33,6 +33,12 @@ var
|
||||
OldPosition, MaxPos: Integer;
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
if csLoading in FControl.ComponentState then
|
||||
begin
|
||||
FPosition := Value;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if Value < 0 then
|
||||
begin
|
||||
SetPosition(0);
|
||||
@ -146,9 +152,9 @@ begin
|
||||
ScrollInfo.fMask := SIF_Range + SIF_Page;
|
||||
GetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo);
|
||||
NewRange := ScrollInfo.nMax - ScrollInfo.nMin;
|
||||
if NewRange<>FRange then
|
||||
if NewRange <> FRange then
|
||||
begin
|
||||
FRange:=NewRange;
|
||||
FRange := NewRange;
|
||||
InvalidateScrollInfo;
|
||||
end;
|
||||
end;
|
||||
@ -405,7 +411,7 @@ begin
|
||||
FRange := AValue;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
//if DebugCondition then
|
||||
DebugLn(['TControlScrollBar.SetRange ',dbgs(Kind),' ',Self,' fRange=',FRange]);
|
||||
DebugLn(['TControlScrollBar.SetRange ',dbgs(Kind),' ',Self,' FRange=',FRange]);
|
||||
{$ENDIF}
|
||||
ControlUpdateScrollBars;
|
||||
end;
|
||||
@ -475,7 +481,7 @@ end;
|
||||
|
||||
function TControlScrollBar.IsScrollBarVisible: Boolean;
|
||||
begin
|
||||
Result:=FVisible;
|
||||
Result := FVisible;
|
||||
if HandleAllocated then
|
||||
Result := GetScrollbarVisible(ControlHandle, IntfBarKind[Kind]);
|
||||
end;
|
||||
@ -499,23 +505,23 @@ end;
|
||||
function TControlScrollBar.ClientSize: integer;
|
||||
begin
|
||||
if Kind = sbVertical then
|
||||
Result:=FControl.ClientWidth
|
||||
Result := FControl.ClientWidth
|
||||
else
|
||||
Result:=FControl.ClientHeight;
|
||||
Result := FControl.ClientHeight;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.ClientSizeWithBar: integer;
|
||||
begin
|
||||
Result:=ClientSize;
|
||||
Result := ClientSize;
|
||||
if not IsScrollBarVisible then
|
||||
dec(Result,GetSize);
|
||||
dec(Result, GetSize);
|
||||
end;
|
||||
|
||||
function TControlScrollBar.ClientSizeWithoutBar: integer;
|
||||
begin
|
||||
Result:=ClientSize;
|
||||
if IsScrollBarVisible then
|
||||
inc(Result,GetSize);
|
||||
inc(Result, GetSize);
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetHorzScrollBar: TControlScrollBar;
|
||||
@ -523,7 +529,7 @@ begin
|
||||
if FControl is TScrollingWinControl then
|
||||
Result := TScrollingWinControl(FControl).HorzScrollBar
|
||||
else
|
||||
Result:=nil;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetVertScrollBar: TControlScrollBar;
|
||||
@ -531,12 +537,12 @@ begin
|
||||
if FControl is TScrollingWinControl then
|
||||
Result := TScrollingWinControl(FControl).VertScrollBar
|
||||
else
|
||||
Result:=nil;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.ScrollBarShouldBeVisible: Boolean;
|
||||
begin
|
||||
Result:=FVisible and (FRange>FPage);
|
||||
Result := FVisible and (FRange > FPage);
|
||||
end;
|
||||
|
||||
// included by forms.pp
|
||||
|
@ -32,6 +32,11 @@ begin
|
||||
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TScrollingWinControl.CreateWnd'){$ENDIF};
|
||||
try
|
||||
inherited CreateWnd;
|
||||
if AutoScroll then
|
||||
begin
|
||||
HorzScrollBar.AutoCalcRange;
|
||||
VertScrollBar.AutoCalcRange;
|
||||
end;
|
||||
UpdateScrollBars;
|
||||
finally
|
||||
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TScrollingWinControl.CreateWnd'){$ENDIF};
|
||||
@ -118,7 +123,7 @@ function TScrollingWinControl.ComputeScrollbars: Boolean;
|
||||
OtherScrollbar: TControlScrollBar;
|
||||
OldAutoRange: LongInt;
|
||||
begin
|
||||
Result:=false;
|
||||
Result := False;
|
||||
OldAutoRange := p_Bar.FAutoRange;
|
||||
p_Bar.FAutoRange := 0;
|
||||
OtherScrollbar := p_Bar.GetOtherScrollBar;
|
||||
@ -129,7 +134,7 @@ function TScrollingWinControl.ComputeScrollbars: Boolean;
|
||||
p_Bar.FAutoRange := 0;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if p_Bar.DebugCondition then
|
||||
DebugLn(['UpdateRange p_Bar.fRange=',p_Bar.fRange,' SBSize=',SBSize,' ClientWidth=',ClientWidth,' FAutoRange=',p_Bar.FAutoRange]);
|
||||
DebugLn(['UpdateRange p_Bar.fRange=',p_Bar.FRange,' SBSize=',SBSize,' ClientWidth=',ClientWidth,' FAutoRange=',p_Bar.FAutoRange]);
|
||||
{$ENDIF}
|
||||
if OldAutoRange <> p_Bar.FAutoRange then
|
||||
Result := True;
|
||||
@ -177,11 +182,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TScrollingWinControl.StoreScrollBars : Boolean;
|
||||
begin
|
||||
Result := not AutoScroll;
|
||||
end;
|
||||
|
||||
class procedure TScrollingWinControl.WSRegisterClass;
|
||||
begin
|
||||
inherited WSRegisterClass;
|
||||
|
Loading…
Reference in New Issue
Block a user