在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
下面这2种方法都能实现对控件和窗体的拖拽
方法1 procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ReleaseCapture; SendMessage(Handle,WM_NCLBUTTONDOWN,HTCAPTION,0); end;
方法2 public
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin posX := Mouse.CursorPos.X - Form1.Left; posY := Mouse.CursorPos.Y - Form1.Top; end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if Shift =[ssLeft] then begin Form1.Left := Mouse.CursorPos.X - posX; // 新的位置 Form1.Top := Mouse.CursorPos.Y - posY; end; end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论