Win32函数实现鼠标拖动窗口
private static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
private static extern bool ReleaseCapture();
private const uint WM_SYSCOMMAND = 0x0112;
private const int WM_SETREDRAW = 11;
private const int SC_MOVE = 61456;
private const int HTCAPTION = 2;
public static voidMoveWindow(IntPtr handle)
{
ReleaseCapture();
SendMessage(handle, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 5);
}
要实现鼠标点击拖动,只需要在鼠标MouseDown事件中 调用MoveWindow方法即可,参数传入窗口句柄。
private void XXXX_MouseDown(object sender, MouseEventArgs e)
{
MoveWindow(XXXX.Handle);
}
叶叶叶 666
页:
[1]