WinForm 拖动、移动窗体

private const int WM_NCLBUTTONDOWN = 0XA1;
        private const int HTCAPTION = 2;
        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SendMessageA")]
        private static extern int SendMessage(int hwnd, int wMsg, int wParam, int lParam);

        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern int ReleaseCapture();

        private void MsgBoxForm_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage((int)this.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
        }

  

posted @ 2018-04-19 10:18  会弹猫的吉他  阅读(170)  评论(0编辑  收藏  举报