I'm making a Rebar
wrapper for .NET. Here's how I've made my control.
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;
}
}
}
I tested my control by adding a REBARBANDINFO
into the control and IT WORKED.
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);
I won't include the implementation of my p/invoke signatures because everything is fine there.
The problem starts here
The control doesn't work the way I've expected, the Rebar cursor isn't respected and Cursor
property takes control over the cursor, it even overrides the resize cursor.
Expectation
Reality
Is that even possible? Yes, it is
Check out this example of a ListView
. It IS possible to make a Control that respects its original cursor messages.
How can I make my Rebar
decide the mouse cursor instead of Cursor
property?
Aditional: I've done my best to ask a good question. I double-checked the question to ensure it can be understood.
RBN_SPLITTERDRAG
orRBN_BEGINDRAG
? (I've not used Rebar before) I'm surprised there is noRBN_DRAG
– TorinRBN_SPLITTERDRAG
and similar notifications (they're not messages) are not useful for this because cursor can only be set while dragging. Don't forget theCursor
property affects the whole control. – MuscatelListView
does more than hit-testing, the cursor even changes when cursor is over the separator – Muscatel