LCL: Isolate setting the control's position from TControlScrollBar.SetPosition. A half-baked attempt to fix #29067.

git-svn-id: trunk@50479 -
This commit is contained in:
juha 2015-11-23 14:15:37 +00:00
parent c9f8dd26db
commit 8c4e943410
4 changed files with 20 additions and 7 deletions

View File

@ -84,7 +84,6 @@ type
FIncrement: TScrollBarInc;
FKind: TScrollBarKind;
FPage: TScrollBarInc;
FPosition: Integer;
FRange: Integer; // if AutoScroll=true this is the needed size of the child controls
FSmooth: Boolean;
FTracking: Boolean;
@ -93,6 +92,7 @@ type
FOldScrollInfoValid: Boolean;
protected
FControl: TWinControl;
FPosition, FPrevPosition: Integer;
function ControlHandle: HWnd; virtual;
function GetAutoScroll: boolean; virtual;
function GetIncrement: TScrollBarInc; virtual;
@ -108,7 +108,8 @@ type
procedure ScrollHandler(var Message: TLMScroll);
procedure SetIncrement(const AValue: TScrollBarInc); virtual;
procedure SetPage(const AValue: TScrollBarInc); virtual;
procedure SetPosition(const Value: Integer); virtual;
procedure SetPosition(const Value: Integer);
procedure SetControlPosition; virtual;
procedure SetRange(const AValue: Integer); virtual;
procedure SetSmooth(const AValue: Boolean); virtual;
procedure SetTracking(const AValue: Boolean);

View File

@ -24,7 +24,7 @@ const
procedure TControlScrollBar.SetPosition(const Value: Integer);
var
OldPosition, MaxPos: Integer;
MaxPos: Integer;
ScrollInfo: TScrollInfo;
begin
if csLoading in FControl.ComponentState then
@ -70,11 +70,11 @@ begin
if Value = FPosition then
exit;
// scroll logical client area of FControl
OldPosition := FPosition;
// now actually set the position
FPrevPosition := FPosition;
FPosition := Value;
if FControl is TScrollingWinControl then
TScrollingWinControl(FControl).ScrollbarHandler(Kind, OldPosition);
// scroll logical client area of FControl
SetControlPosition;
// check that the new position is also set on the scrollbar
if HandleAllocated and (GetScrollPos(ControlHandle, IntfBarKind[Kind]) <> FPosition) then
@ -94,6 +94,12 @@ begin
end;
end;
procedure TControlScrollBar.SetControlPosition;
begin
if FControl is TScrollingWinControl then
TScrollingWinControl(FControl).ScrollbarHandler(Kind, FPrevPosition);
end;
function TControlScrollBar.GetIncrement: TScrollBarInc;
begin
Result := FIncrement;

View File

@ -11,6 +11,11 @@
{ TMemoScrollbar }
procedure TMemoScrollbar.SetControlPosition;
begin
//TCustomMemo(FControl).ScrollBy(FPosition - FPrevPosition); No good!
end;
function TMemoScrollbar.GetHorzScrollBar: TControlScrollBar;
begin
Result:=TCustomMemo(FControl).HorzScrollBar;

View File

@ -804,6 +804,7 @@ type
TMemoScrollbar = class(TControlScrollBar)
protected
procedure SetControlPosition; override;
function GetHorzScrollBar: TControlScrollBar; override;
function GetVertScrollBar: TControlScrollBar; override;
public