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;

posted @ 2015-09-09 13:30  Shauna.Vayne  阅读(216)  评论(0编辑  收藏  举报