步骤如下:
1、在窗体的private声明中写下:
procedure WMNCHitTest(var Msg: TWMNCHitTest) ; message WM_NCHitTest;
2、在implement声明:
procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest) ;
begin
inherited;
if Msg.Result = htClient then Msg.Result := htCaption;//欺骗windows
end;
以上代码,只有鼠标是在窗体上移动拖拉时才有效。如果窗体上有panel,而且是alClient,那么以上代码则无效。
需要加入以下代码:







还有其他变通情况:
if Msg.Result = htClose then Msg.Result := htNowhere;
if Msg.Result = htCaption then Msg.Result := htClient;// 不给移动窗体