Hello, how can I improve the code so that it works, I mean moving the image with the mouse together with scrollbars?
var
IsPanning: Boolean = False;
LastPoint: TPoint;
procedure TForm1.ImgView32_1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
IsPanning := True;
LastPoint := Point(X, Y);
end;
end;
procedure TForm1.ImgView32_1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
dx, dy: Integer;
begin
if IsPanning then
begin
dx := X - LastPoint.X;
dy := Y - LastPoint.Y;
ImgView32_1.Offset := Point(ImgView32_1.Offset.X + dx, ImgView32_1.Offset.Y + dy);
LastPoint := Point(X, Y);
end;
end;
procedure TForm1.ImgView32_1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
IsPanning := False;
end;