简单!给分吧!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
MYHandle:HWND;
procedure WMTimer(var Message: TMessage); message WM_TIMER;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMTimer(var Message: TMessage);
var
p:TPoint;
begin
GetCursorPos(p);
if screen.Width-p.x<=5 then
begin
self.Left:=p.X-self.Width;
self.top:=p.y;
end
else
begin
if Screen.Height-p.y<=5 then
begin
self.Left:=p.X;
self.top:=p.y-self.Height;
end
else
begin
self.Left:=p.X;
self.top:=p.y;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MYHandle := AllocateHWnd(WndProc);
KillTimer(MYHandle, 1);
SetTimer(MYHandle, 1, 5, nil);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
KillTimer(MYHandle, 1);
end;
end.