I have a custom control I will be deriving from TScrollingWinControl.
I am intercepting the WM_HSCROLL and WM_VSCROLL messages and what I would like to do is make the scrollbox snap to a position when scrolling. So for example, instead of smooth scrolling horizontally, instead the scrollbar will jump to the nearest snap/increment. The following worked in Delphi (though cannot test as no longer installed) but I seem unable to get it to work in Lazarus:
TMyScrollBox = class(TScrollingWinControl)
private
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
........
procedure TMyScrollBox.WMHScroll(var Message: TWMHScroll);
begin
Message.Pos := (Message.Pos div 16) * 16; // increment by 16 for example
inherited;
end;
procedure TMyScrollBox.WMVScroll(var Message: TWMVScroll);
begin
Message.Pos := (Message.Pos div 16) * 16; // increment by 16 for example
inherited;
end;
I know the HorzScrollBar and VertScrollBar has a increment property but that only applies when using the scrollbar arrows, I need the same behavior for actually moving the scrollbars.
I also tried changing HorzScrollBar.Position for example but this bugged even more.
Please advise