窗体的拖动

直接贴代码

-----------------------------------

有更好的方法可以讨论讨论哈

==================================

[DllImport("user32.dll")]
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wparam, int lparam);
        private void panzHead_MouseDown(object sender, MouseEventArgs e) {
            if (e.Button == MouseButtons.Left) {
                // 释放鼠标使能够手动操作
                //ReleaseCapture();
                this.panzHead.Capture = false;
                // 拖动窗体
                //SendMessage(this.Handle, 0x0112, 0xF010 + 0x0002, 0);
                SendMessage(this.Handle, 0x00A1, 2, 0);
            }
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章