I've got a WPF dialog that I want to display in a Win32 app as a non-modal Window. Calling window.Show() correctly displays the window, and all mouse events are handled properly by it, but all keyboard event are handled by the parent Win32 window, so that even if a user has given focus to a textbox, any typed text shows up in the parent Win32 window!
This seems to be a known problem in WinForms/WPF interop, and is fixed in that case by calling ElementHost.EnableModelessKeyboardInterop
before displaying the dialog. This causes a new message filter to be added to the WinForms message loop, so that keyboard events can be intercepted and appropriately routed to the WPF dialog.
Unfortunately my host application is not a WinForms app, so I don't have the option to call EnableModelessKeyboardInterop
. Is there any way to do a similar thing in a Win32 app?