procedure TForm1.hitit(var msg: TWMNCHITTEST);
var
pt:TPoint;
begin
pt.x:=msg.XPos;
pt.y:=msg.YPos;
pt:=ScreenToClient(pt);
if ptInRect(Rect(lpRect.Right-5,lpRect.Top+5,
lpRect.Right+5,lpRect.Bottom-5),pt) then
msg.Result:=HTRIGHT;//右边
if ptInRect(Rect(lpRect.Left-5,lpRect.Top+5,
lpRect.Left+5,lpRect.Bottom-5),pt) then
msg.Result:=HTLEFT; //左边
if ptInRect(Rect(lpRect.Left+5,lpRect.Top-5,
lpRect.Right-5,lpRect.Top+5),pt) then
msg.Result:=HTTOP; //上边
if ptInRect(Rect(lpRect.Left+5,lpRect.Bottom-5,
lpRect.Right-5,lpRect.Bottom+5),pt) then
msg.Result:=HTBOTTOM; //下边
if ptinRect(Rect(lpRect.Left-5,lpRect.Top-5,
lpRect.Left+5,lpRect.Top+5),pt) then
msg.Result:=HTTOPLEFT;//左上角
if ptInRect(Rect(lpRect.Right-5,lpRect.Bottom-5,
lpRect.Right+5,lpRect.Bottom+5),pt) then
msg.Result:=HTBOTTOMRIGHT;//右下角
if ptInRect(Rect(lpRect.Left-5,lpRect.Bottom-5,
lpRect.Left+5,lpRect.Bottom+5),pt) then
msg.Result:=HTBOTTOMLEFT; //左下角
if ptInRect(Rect(lpRect.Right-5,lpRect.Left-5,
lpRect.Right+5,lpRect.Left+5),pt) then
msg.Result:=HTTOPRIGHT; //右上角
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
lpRect:=ClientRect;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
lpRect:=ClientRect;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;