Hier ein kleiner Anstoß dazu:
Delphi-Quellcode:
private {...}
canMove: Boolean;
{...}
procedure TForm1.FormCreate(Sender: TObject);
begin
canMove := False;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
canMove := True;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
p: TPoint;
begin
GetCursorPos(p);
if canMove then
begin
Image1.Top := p.Y - (Image1.Height div 2);
Image1.Left := p.X - (Image1.Width div 2);
end;
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
canMove := False;
end;