2017년 2월 7일 화요일
[Delphi] How to pan an image with the mouse in Scrollbox
Here is the correct coding. The FLastX/Y value needs to be adjusted by the amount that the image was moved.
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Dx, Dy: Integer;
begin
if FMouseIsDown then
begin
Dx := X - FLastX;
Dy := y - FLasty;
VertScrollBar.Position := VertScrollBar.Position - (Dy * Image1.height div vertscrollbar.Range);
HorzScrollBar.Position := HorzScrollBar.Position - (Dx * Image1.width div horzscrollbar.Range);
FLastX := X - Dx;
FLastY := Y - Dy;
end
end;
HorzScrollBar.Position := HorzScrollBar.Position - (Dx * Image1.width div horzscrollbar.Range);
FLastX := X - Dx;
FLastY := Y - Dy;
end
end;
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기