C# 如何通过HTCAPTION捕获鼠标移动

C# 如何通过HTCAPTION捕获鼠标移动,c#,mousemove,C#,Mousemove,我有一个表单,它将所有背景设置为HTCAPTION,如下所示的源代码 protected override void WndProc(ref Message m) { base.WndProc(ref m); switch(m.Msg) { case Global.WM_NCHITTEST: Point mouseCursor = PointToClient(Cursor.P

我有一个表单,它将所有背景设置为HTCAPTION,如下所示的源代码

    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);

        switch(m.Msg)
        {
            case Global.WM_NCHITTEST:
                Point mouseCursor = PointToClient(Cursor.Position);

                if (mouseCursor.X < borderSize && mouseCursor.Y < borderSize)
                    m.Result = (IntPtr)Global.HTTOPLEFT;
                else if (mouseCursor.X < borderSize && mouseCursor.Y > Height - borderSize)
                    m.Result = (IntPtr)Global.HTBOTTOMLEFT;
                else if (mouseCursor.X < borderSize)
                    m.Result = (IntPtr)Global.HTLEFT;
                else if (mouseCursor.X > Width - borderSize && mouseCursor.Y < borderSize)
                    m.Result = (IntPtr)Global.HTTOPRIGHT;
                else if (mouseCursor.X > Width - borderSize && mouseCursor.Y > Height - borderSize)
                    m.Result = (IntPtr)Global.HTBOTTOMRIGHT;
                else if (mouseCursor.X > Width - borderSize)
                    m.Result = (IntPtr)Global.HTRIGHT;
                else if (mouseCursor.Y < borderSize)
                    m.Result = (IntPtr)Global.HTTOP;
                else if (mouseCursor.Y > Height - borderSize)
                    m.Result = (IntPtr)Global.HTBOTTOM;
                else
                    m.Result = (IntPtr)Global.HTCAPTION;
                break;
        }
    }
如何捕获MouseMove事件?

在VB.net中,它是

MyBase.WndProc(m)
所以,如果我错了,请纠正我,但我猜是C

this.WndProc(m)
?? 把它放在你的if声明之前

this.WndProc(m)