unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure Panel1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Panel1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure Panel1MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure FormMouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Panel1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
var
P:TPoint;
begin
if Panel1.Tag=0 then
Exit;
P.x:=X;
P.y:=Y;
with Panel1do
begin
P:=Form1.ScreenToClient(ClientToScreen(P));
Left:=P.x-X+1;
Top:=P.y-Y+1;
Repaint;
end;
end;
procedure TForm1.Panel1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
Panel1.Tag:=1;
end;
procedure TForm1.Panel1MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
Panel1.Tag:=0;
end;
procedure TForm1.FormMouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
Panel1.Tag:=0;
end;
end.