winform学习(9)无边框拖动窗体
去除边框
选中窗体,在属性中找到FormBorderStyle,设置为None
实现无边框拖动
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
private void Login_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, 0x0112, 0xF012, 0);
}
给窗体添加MouseDown事件:Login_MouseDown,即可实现功能。