Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • Thanks, great info! But how is it possible low level hooks do not work when WPF uses wrappers around standard windows messages? It works great in any non-WPF applications, but the apps using WPF do not behave as expected (I can correctly detect mouse events in a WPF application, but I can't cancel that event, even though it works in any other non-WPF application).
    – Paya
    Commented Mar 1, 2011 at 20:21
  • Maybe you should post an example? By the way, if you want to manage WPF input, you should look at the InputManager class. Commented Mar 1, 2011 at 21:01
  • 1
    Thanks. I found that your constant value for WM_RBUTTONUP is wrong. It should be 0x205. And there will be no context menu in WPF application ;) Commented Mar 2, 2011 at 13:48
  • 1
    Ah, thanks. I've quickly created that example, so in rush I've missed that (I use different class with correct WM_RBUTTONUP for development). I've done further testing and have discovered where the problem lies - I use computer with stylus for development, and I thought system just translates stylus input into mouse messages and that's it (for stylus-unaware apps). So it works correctly with standard Win32 app (stylus right click does nothing), but WPF apps are still able to detect that click, because they are stylus-aware (didn't know that). So now I need something like low level stylus hook.
    – Paya
    Commented Mar 2, 2011 at 14:18
  • 2
    Unfortunately, I never worked with stylus and have no touch screen to test WPF stylus behavior. But I can tell you that it is very interesting how it works! HwndStylusInputProvider handles only WM_TABLET_FLICK and WM_TABLET_QUERYSYSTEMGESTURESTATUS and raises no events. There is another class called PenThreadWorker. It launches a new thread called "Stylus Input". This thread queries input events using GetPenEvent and GetPenEventMultiple functions from native DLL called "penimc.dll". Then it fires Stylus events corresponding to interop result. Commented Mar 3, 2011 at 8:04