1.鼠标在客户区拖动窗口
重载消息函数 procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
begin
inherited; //不可缺少
if (=Message.Result = HTCLIENT) then
Message.Result := HTCAPTION;
end;
2.鼠标在 Panel 上拖动窗口
在 Panel 的 OnMouseMove 事件中写入下代码:
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(Self.Handle, WM_SYSCOMMAND, SC_MOVE + 1, 0);
end;
原文地址:http://www.cnblogs.com/spiritofcloud/p/3978330.html