unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MPos:TPoint;
implementation
{$R *.DFM}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
MPos.X := X;
MPos.Y := Y;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var i:integer;
begin
if ssLeft in Shift then
begin
i:=50;
if (Form1.Left - (MPos.X-X))>i then
Form1.Left := Form1.Left - (MPos.X-X)
else Form1.Left :=0;
if (Form1.Top - (MPos.Y-Y))>i then
Form1.Top := Form1.Top - (MPos.Y-Y)
else Form1.Top := 0;
end;
end;
end.