C# Winform无边框窗体实现界面拖动
csharp
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int VM_NCLBUTTONDOWN = 0xA1; // 定义鼠标左键按下
public const int HTCAPTION = 2;
//调用方法
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
// 为当前应用程序释放鼠标捕获
ReleaseCapture();
// 发送消息 让系统误以为在标题栏上按下鼠标
SendMessage((IntPtr)this.Handle, VM_NCLBUTTONDOWN, HTCAPTION, 0);
}