C#拖动无边框窗体
1 [DllImport("user32.dll")]
2 public static extern bool ReleaseCapture();
3 [DllImport("user32.dll")]
4 public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
5 public const int WM_SYSCOMMAND = 0x0112;
6 public const int SC_MOVE = 0xF010;
7 public const int HTCAPTION = 0x0002;
8 private void lblMain_MouseMove(object sender, MouseEventArgs e)
9 {
10 if (e.Button == MouseButtons.Left)
11 {
12 ReleaseCapture();
13 SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
14 }
15 }