
12.12.2010, 02:25
|
 |
Новичок
|
|
Регистрация: 22.11.2010
Сообщения: 99
Репутация: 47
|
|
Я обычно делаю так -
Код:
...
var
Form1: TForm1;
CursorPos : TPoint;
FormPos : TPoint;
Drag : boolean;
implementation
{$R *.dfm}
...
procedure TForm1.OnIdle(Sender: TObject; var Done: boolean);
var Point: TPoint;
begin
if Drag then
begin
GetCursorPos(Point);
Left := FormPos.X + Point.X - CursorPos.X;
Top := FormPos.Y + Point.Y - CursorPos.Y;
end;
end;
procedure TForm1.Image1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
Drag := True;
FormPos.X := Left;
FormPos.Y := Top;
GetCursorPos(CursorPos);
end;
end;
procedure TForm1.Image1MouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then Drag := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnIdle := OnIdle;
end;
|