March 24th, 2009, 04:22 PM
[RESOLVED] Windows Messages in WPF
I have a WPF app that I want to be able to handle certain Windows Messages that other apps send to it. In Windows Forms, I could overload the OnNotifyMessage method in my form and handle arbitrary messages there. How do I do this in WPF? All I know about the messages are the message ids (e.g., unsigned int WM_MyMessage = 0x8001).
March 24th, 2009, 04:50 PM
Re: Windows Messages in WPF
After a bit more searching, I've found a solution:
// Handler must be added once the window is loaded
void Main_Loaded(object sender, RoutedEventArgs e)
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
// Handle messages here
The solution was originally found here: http://social.msdn.microsoft.com/For...-cb7cdb27bd83/
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!