Skip to content

Commit

Permalink
Fix non-working scrolling with a horizontal mouse wheel in grids, by …
Browse files Browse the repository at this point in the history
…preferring TWMScroll.Pos over TScrollInfo.nTrackPos (always 0). Closes #355
  • Loading branch information
ansgarbecker committed Mar 20, 2024
1 parent f038db4 commit 9b94b04
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions components/virtualtreeview/Source/VirtualTrees.BaseTree.pas
Expand Up @@ -6532,24 +6532,6 @@ procedure TBaseVirtualTree.WMGetDlgCode(var Message: TWMGetDlgCode);

procedure TBaseVirtualTree.WMHScroll(var Message: TWMHScroll);

//--------------- local functions -------------------------------------------

function GetRealScrollPosition: TDimension;

var
SI: TScrollInfo;
Bar: Integer;

begin
SI.cbSize := SizeOf(TScrollInfo);
SI.fMask := SIF_TRACKPOS;
Bar := SB_HORZ;
GetScrollInfo(Bar, SI);
Result := SI.nTrackPos;
end;

//--------------- end local functions ---------------------------------------

var
RTLFactor: Integer;

Expand Down Expand Up @@ -6582,9 +6564,11 @@ procedure TBaseVirtualTree.WMHScroll(var Message: TWMHScroll);
begin
DoStateChange([tsThumbTracking]);
if UseRightToLeftAlignment then
SetOffsetX(-FRangeX + ClientWidth + GetRealScrollPosition)
SetOffsetX(-FRangeX + ClientWidth + Message.Pos)
else
SetOffsetX(-GetRealScrollPosition);
SetOffsetX(-Message.Pos);
// Fix unstyled scrollbar in some cases, while causing flicker:
UpdateScrollBars(True);
end;
SB_TOP:
SetOffsetX(0);
Expand Down

0 comments on commit 9b94b04

Please sign in to comment.