它是自定义了WM_NCHITTEST消息的。具体代码如下:
procedure WMNCHITTEST(var m:TWMNCHITTEST);
var
tpclient,tpscreen:TPoint;
ileft,iright,ibottom,itop:integer;
begin
inherited;
tpclient.x:=0;
tpclient.y:=0;
tpscreen:=ClientToScreen(tpClient);
itop:=tpscreen.y;
ibottom:=itop+self.Height;
ileft:=tpscreen.x;
iright:=ileft+self.Width;
if (M.XPos>=iright-3) and (M.YPos>itop+25) and (M.YPos<ibottom-3) and (MainForm.WindowState<>wsMaximized) then
//右边界
M.Result:=HTRIGHT;
if (M.XPos<=ileft+3) and (M.YPos>itop+25) and (M.YPos<ibottom-3) and (MainForm.WindowState<>wsMaximized) then
//左边界
M.Result:=HTLEFT;
if (M.YPos>=ibottom-3) and (M.XPos>ileft+3) and (M.XPos<iright-3)and (MainForm.WindowState<>wsMaximized) then
//下边界
M.Result:=HTBOTTOM;
if (M.XPos>=iright-3) and (M.YPos<=itop+25)and (MainForm.WindowState<>wsMaximized) then
//右上角
M.Result:=HTTOPRIGHT;
if (M.XPos>=iright-3) and (M.YPos>=ibottom-3)and (MainForm.WindowState<>wsMaximized) then
//右下角
M.Result:=HTBOTTOMRIGHT;
if (M.XPos<=ileft+3) and (M.YPos<=itop+25)and (MainForm.WindowState<>wsMaximized) then
//左上角
M.Result:=HTTOPLEFT;
if (M.XPos<=ileft+3) and (M.YPos>=ibottom-3) and (MainForm.WindowState<>wsMaximized) then
//左下角
M.Result:=HTBOTTOMLEFT;
if (M.YPos<MainForm.Top+20) and (M.XPos<(MainForm.Width+MainForm.Left-63)) and (M.XPos>MainForm.Left+25) and (MainForm.WindowState=wsNormal) then
m.result:=htcaption;
if (M.YPos<MainForm.Top+20) and (M.XPos<(MainForm.Width+MainForm.Left-63)) and (MainForm.WindowState=wsMaximized) then
m.Result:=Htmenu;