procedure TxxxxForm.FormMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const
sc_DragMove: Integer = $F012;
begin
if ssCtrl in Shift then //判断“Ctrl”键是否按下
Begin
ReleaseCapture; //释放鼠标事件的对象
//(Sender as TWinControl).PerForm(wm_SysCommand, sc_DragMove, 0);
//实现在组件内移动,如果是顶层,就是移动窗体
//self.perform(WM_SYSCOMMAND, sc_DragMove, 0);
//实现移动窗体
//SendMessage(Self.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
//实现移动窗体
end;
end;
以上注释的三段#9,#11,#13都可以起到移动窗体的效果。
procedure TxxxxForm.FormMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const
sc_DragMove: Integer = $F012;
begin
if ssCtrl in Shift then //判断“Ctrl”键是否按下
Begin
ReleaseCapture; //释放鼠标事件的对象
//(Sender as TWinControl).PerForm(wm_SysCommand, sc_DragMove, 0);
//实现在组件内移动,如果是顶层,就是移动窗体
//self.perform(WM_SYSCOMMAND, sc_DragMove, 0);
//实现移动窗体
//SendMessage(Self.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
//实现移动窗体
end;
end;