鼠标点击可拖动窗体方法

来源:互联网 发布:学电脑编程要多少钱 编辑:程序博客网 时间:2024/05/18 03:35
[DllImport("User32.DLL")]public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);[DllImport("User32.DLL")]public static extern bool ReleaseCapture();public const uint WM_SYSCOMMAND = 0x0112;public const int SC_MOVE = 61456;public const int HTCAPTION = 2;private void Form1_MouseDown(object sender, MouseEventArgs e){ReleaseCapture();SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);}