I have a TImage component in a ScrollBox, where the image is larger than the ScrollBox. I can use the scroll bars to move the image around in the ScrollBox, but I want to use the mouse. I want to click on the image and drag it to move it in the ScrollBox. As I do this, the ScrollBox's scroll bars should move correspondingly.
I am going to set the image cursor to crHandPoint so that people will expect that they can move the image around.
My question is, how do I make this work?
procedure TfrmKaarte.imgKaartCanvasMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
bPanning:=True;
pt := Mouse.CursorPos;
end;
procedure TfrmKaarte.imgKaartCanvasMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if bPanning=True then
begin
imgKaartCanvas.Left:=X+imgKaartCanvas.Left-pt.X;
imgKaartCanvas.Top:=Y+imgKaartCanvas.Top-pt.Y;
end;
end;
procedure TfrmKaarte.imgKaartCanvasMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
bPanning:=False;
end;