I've also needed to solve a similar problem recently. Abel's answer set me on the right direction. Here is a complete example of how I did it, by changing a normal window into a message-only window:
class MessageWindow : Form {
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
public MessageWindow() {
var accessHandle = this.Handle;
}
protected override void OnHandleCreated(EventArgs e) {
base.OnHandleCreated(e);
ChangeToMessageOnlyWindow();
}
private void ChangeToMessageOnlyWindow() {
IntPtr HWND_MESSAGE = new IntPtr(-3);
SetParent(this.Handle, HWND_MESSAGE);
}
protected override void WndProc(ref Message m) {
// respond to messages here
}
}
Pay attention to the constructor: I've found that I need to access the Handle property or otherwise the OnHandleCreated method won't get called. Not sure of the reason, perhaps someone can explain why.
I believe my sample code also would answer a related question: How do I create a message-only window from windows forms?
NC_*
messages? Just like the hover in the titlebar, this might also be a "non-client area". Also: what do you mean with window messages? Like when a mouse is hovered over the minimized form? – Mcclary