mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 19:23:49 +02:00
LCL: TScrollingWinControl.ScrollInView or TScrollBox.ScrollInView scroll only when ScrollBar is visible, see Issue #38838 forum entries.
git-svn-id: trunk@65085 -
This commit is contained in:
parent
cea34fad16
commit
74d996c632
@ -250,30 +250,33 @@ procedure TScrollingWinControl.ScrollInView(AControl: TControl);
|
||||
var
|
||||
LRect: TRect;
|
||||
LPoint: TPoint;
|
||||
LHorzVisible, LVertVisible: Boolean;
|
||||
begin
|
||||
if AControl = nil then Exit;
|
||||
if (AControl = nil) or not IsParentOf(AControl) then Exit;
|
||||
LHorzVisible := HorzScrollBar.IsScrollBarVisible;
|
||||
LVertVisible := VertScrollBar.IsScrollBarVisible;
|
||||
if not LHorzVisible and not LVertVisible then Exit;
|
||||
LRect := Rect(0, 0, AControl.Width, AControl.Height);
|
||||
LPoint := AControl.ClientToParent(Point(0, 0), Self);
|
||||
LRect.Left := LPoint.x;
|
||||
LRect.Top := LPoint.y;
|
||||
LPoint := AControl.ClientToParent(Point(AControl.Width, AControl.Height), Self);
|
||||
LRect.Right := LPoint.x;
|
||||
LRect.Bottom := LPoint.y;
|
||||
if LRect.Left < 0 then
|
||||
HorzScrollBar.Position := HorzScrollBar.Position + LRect.Left
|
||||
else if LRect.Right > ClientWidth then
|
||||
begin
|
||||
if LRect.Right - LRect.Left > ClientWidth then
|
||||
LRect.Right := LRect.Left + ClientWidth;
|
||||
HorzScrollBar.Position := HorzScrollBar.Position + LRect.Right - ClientWidth;
|
||||
end;
|
||||
if LRect.Top < 0 then
|
||||
VertScrollBar.Position := VertScrollBar.Position + LRect.Top
|
||||
else if LRect.Bottom > ClientHeight then
|
||||
begin
|
||||
if LRect.Bottom - LRect.Top > ClientHeight then
|
||||
LRect.Bottom := LRect.Top + ClientHeight;
|
||||
VertScrollBar.Position := VertScrollBar.Position + LRect.Bottom - ClientHeight;
|
||||
end;
|
||||
OffsetRect(LRect, LPoint.x, LPoint.y);
|
||||
if LHorzVisible then
|
||||
if LRect.Left < 0 then
|
||||
HorzScrollBar.Position := HorzScrollBar.Position + LRect.Left
|
||||
else if LRect.Right > ClientWidth then
|
||||
begin
|
||||
if LRect.Right - LRect.Left > ClientWidth then
|
||||
LRect.Right := LRect.Left + ClientWidth;
|
||||
HorzScrollBar.Position := HorzScrollBar.Position + LRect.Right - ClientWidth;
|
||||
end;
|
||||
if LVertVisible then
|
||||
if LRect.Top < 0 then
|
||||
VertScrollBar.Position := VertScrollBar.Position + LRect.Top
|
||||
else if LRect.Bottom > ClientHeight then
|
||||
begin
|
||||
if LRect.Bottom - LRect.Top > ClientHeight then
|
||||
LRect.Bottom := LRect.Top + ClientHeight;
|
||||
VertScrollBar.Position := VertScrollBar.Position + LRect.Bottom - ClientHeight;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TScrollingWinControl.Loaded;
|
||||
|
Loading…
Reference in New Issue
Block a user