H
hlsl
Unregistered / Unconfirmed
GUEST, unregistred user!
请看下面的代码:注意,将窗体BorderStyle设置为bsNone,<br>窗体上如果放置一个alClient的Panel,这个代码就不起作用了[]。<br>换成 <br>procedure WMHitTest(Msg: TMessage);message WM_NCHITTEST;<br>实现也是一样的。[?]<br><br>代码如下:<br>interface<br><br>TForm1 = Class{TForm)<br>...<br>protected<br>procedure WndProc(var Message: TMessage); override;<br>end;<br>。。。<br><br>implementation<br><br>procedure TForm1.WndProc(var Message: TMessage);<br>var<br> Pt: TPoint;<br>Begin<br> if Message.Msg <> WM_NCHITTEST then<br> begin<br> inherited WndProc(Message);<br> Exit;<br> end;<br><br> Pt := Point(Message.LParamLo,Message.LParamHi);<br> if (Pt.X < 5) and (Pt.Y < 5) then<br> Message.Result := htTopLeft<br> else if (Pt.X > Width - 5) and (Pt.Y < 5) then<br> Message.Result := htTopRight<br> else if (Pt.X > Width - 5) and (Pt.Y > Height - 5) then<br> Message.Result := htBottomRight<br> else if (Pt.X < 5) and (Pt.Y > Height - 5) then<br> Message.Result := htBottomLeft<br> else if (Pt.X < 5) then<br> Message.Result := htLeft<br> else if (Pt.Y < 5) then<br> Message.Result := htTop<br> else if (Pt.X > Width - 5) then<br> Message.Result := htRight<br> else if (Pt.Y > Height - 5) then<br> Message.Result := htBottom<br> else<br> inherited;<br>end;