如何让 Rebar 的 .NET 包装器决定鼠标光标?

How can I let .NET wrapper for Rebar decide the mouse cursor?

我正在为 .NET 制作一个 Rebar 包装器。这是我控制的方式。

public class Rebar : Control {

    public Rebar() : base() {
        //Control won't even work if I let UserPaint enabled
        SetStyle(ControlStyles.UserPaint, false);
    }

    protected override CreateParams CreateParams {
        get {
            CreateParams cp = base.CreateParams;
            cp.ClassName = "ReBarWindow32"; //REBARCLASSNAME
            cp.ExStyle |= 0x00000080; //WS_EX_TOOLWINDOW
            //Windows Forms will control the position and size, not the native control
            cp.Style |= 0x00000004 | 0x00000008; //CCS_NORESIZE and CCS_NOPARENTALIGN
            return cp;
        }
    }

}

我通过在控件中添加 REBARBANDINFO 来测试我的控件,它工作正常。

REBARBANDINFO info = new REBARBANDINFO();
info.cbSize = Marshal.SizeOf(typeof(REBARBANDINFO));
info.fMask = RBBIM_TEXT; // 0x00000004
info.lpText = "example";
SendMessage(this.Handle, RB_INSERTBANDW, -1, ref myband);

我不会包括我的 p/invoke 签名的实现,因为那里一切都很好。

问题从这里开始

该控件没有按我预期的方式工作,Rebar 光标不受尊重,Cursor 属性 控制了光标,它甚至覆盖了调整大小光标。

预期

现实

这可能吗?是的,就是

查看 ListView 的示例。可以制作一个尊重其原始光标消息的控件。

如何让我的 Rebar 决定鼠标光标而不是 Cursor 属性?

附加:我已经尽力问了一个好问题。我仔细检查了问题以确保它可以被理解。

Control class 处理 WM_SETCURSOR 并有自己的逻辑。

作为一个选项,您可以覆盖 WndProc 并让 DefWndProc 处理 WM_SETCURSOR:

const int WM_SETCURSOR = 0x0020;
protected override void WndProc(ref Message m)
{
    if (m.Msg == WM_SETCURSOR)
        base.DefWndProc(ref m);
    else
        base.WndProc(ref m);
}