I've never done any windows programming prior to .net, so
I'm not really familiar with internal workings of windows.
Here is what I got so far, and this seems to work.
This is part of my tool window:
const int WM_NCACTIVATE = 0x0086;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCACTIVATE)
{
if (m.WParam == (IntPtr)1)
{
MainForm.DoWndProc(m);
base.WndProc(ref m);
}
else
{
m.WParam = (IntPtr)1;
base.WndProc(ref m);
}
}
else
base.WndProc (ref m);
}
I'm not really sure about MainForm.DoWndProc. I just
wrote this so that the main window doesn't lose it's
active title bar when user switches to the toolbar
window, so I just send a fake WM_NCACTIVATE message to
main window.
It works, but there are few problems. When I have another
window on top of main window, or open modal dialog, the
tool window always stays active.
I wish there was just some property to be set on a form
to indicate that it's toolbar window and always should be
active.