If the mouse is inside the scrollbox but not over the TImage the TImage scrolls as expected with the mousewheel.
Note this may only be a problem on Windows.
Here is my workaround.
Create a handler for the scrollbox’s MouseWheelEvent with the following code.
procedure TForm1.ScrollBox1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); var inc : integer; begin inc := 16; // choose a value for the increment you desire if WheelDelta > 0 then inc := -16; ScrollBox1.VertScrollBar.Position := ScrollBox1.VertScrollBar.Position + inc; end;Set this procedure as the image’s MouseWheelEvent handler also.
Now the image should scroll the same when the mouse is over the image or over the scrollbox.
Note that right clicking on the scrollbox’s scrollbar will popup a menu with some options but this will not be the case for the image.
No comments:
Post a Comment