Delphi 移动窗体

移动窗体

  • 使用非标题栏移动窗体(在窗体中增加私有方法,如下)
procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  DefaultHandler(msg);
  if Msg.Result=HTCLIENT then
     Msg.Result:=HTCAPTION;
end;
  • 方法2
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if(ssLeft in Shift) then
  begin
    ReleaseCapture;
    SendMessage(Self.Handle,WM_SYSCOMMAND,SC_MOVE+1,0);
  end;
end;
posted @ 2023-06-09 11:57  丹心石  阅读(95)  评论(0编辑  收藏  举报