I am building a form in C# that uses the WM_NCHITEST
event in the WndProc
function. It works perfectly with no controls on the page, but when I added a panel to the page my WndProc
function stopped receiving WM_NCHITEST
events. Any idea what I can do to stop this?
UPDATE: My window in normally borderless, but when I do run it in bordered mode the WM_NCHITTEST
event is called when the cursor mouses over the window frame, leaving me to think that the form size control I have (Chromium Embedded Web Browser) is intercepting the messages. Any way to wrest WndProc control back from a unrully window?
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0083) //WM_NCAlSIZE
{
if (borderless)
{
return; //Works even with a control on the page.
}
}
if (m.Msg == 0x0084) //WM_NCHITEST
{
Debug.Print("If there is a control on the page I won't print :(");
}
base.WndProc(ref m);
}
There are 2 complications running Chromium Embedded Web Browser firstly it creates its own window and attaches as a child to yours which means you need to intercept the WndProc of the child window. Secondly CefSharp runs with
multi_threaded_message_loop=true
which actually fires up a new thread to process messages for the browser which means you need to be a little careful going back and forth from your UI thread and its one.The solution involves liberal use of PInvoke so I have made a gist for it.
Method to watch a child window messages specifically for use with CefSharp Chromium Embedded Web Browser