C#实现全窗体范围拖动

using System.Runtime.InteropServices;
        [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 MouseMove_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(this.Handle, 0x0112, 0xF012, 0);
        }


Windows 的 API 果然强大啊.以前要实现全窗口拖动, 要写鼠标按下和抬起事件, 很是麻烦, 偶尔还会出现 BUG
今天在网上查一些资料的时候, 无意中发现另一种办法, 非常方便, 调用系统的 API 来实现的, 效果也很好


posted @ 2015-05-22 17:05  网事  阅读(402)  评论(0编辑  收藏  举报