winform中主窗体可以实现拖动代码
[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_1(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
ReleaseCapture();
SendMessage(Handle, 0xA1, 0x02, 0); } }
引入命名空间:using System.Runtime.InteropServices;