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).
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);