引入命名空间using System.Runtime.InteropServices;
声明API函数
[DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);
在窗体的鼠标单击事件中引用
private void Frm_Login_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(base.Handle, 0x112, 0xf012,0); }
这样便可支持鼠标拖动无边框窗体