C#通过拖动窗体移动窗口

来源:互联网 发布:js 树形结构 复选框 编辑:程序博客网 时间:2024/05/20 11:46

   private const int WM_NCHITTEST = 0x84;
        private const int HTCLIENT = 0x1;
        private const int HTCAPTION = 0x2;

 

protected override void WndProc(ref Message m)
        {
       
            switch (m.Msg)
            {
                case WM_NCHITTEST:
                    base.WndProc(ref m);
                    if ((int)m.Result == HTCLIENT)
                        m.Result = (IntPtr)HTCAPTION;
                    return;
                  //  break;
            }
            base.WndProc(ref m);
        }