I have a WPF application that has several WindowsFormsHost controls. I'm trying to track the mouse position inside of my application when it is maximized in full-screen mode. If the user puts the mouse near the top screen, I'd like to display a Window with additional menus.
I can use:
- Window.PreviewMouseMove
- InputManager.PreProcessInput, or even
- HwndSource.FromHwnd(WindowInteropHelper(mainWindow).Handle).AddHook(...)
to receive move events so long as the mouse doesn't move over a WindowsFormsHost (if the user does this, I do not receive an event). I think the root problem is because WPF uses a separate HWND for each WindowsFormsHost.
Is there a good way to track the mouse movements across my application without having to manually find each WindowsFormsHost and subscribe to its mouse move events? I'd also like to avoid a global Windows mouse 开发者_如何学Clistener if possible.
I don't think there is a good solution besides using a global mouse hook as outlined here along with a function like Visual.PointFromScreen to translate the global screen coordinate to an application local coordinate.
精彩评论