1
votes

I'm developing a program where I've had to add a keyboard shortcuts system.

The problem is it uses a third party OCX for a part of its display, and it is catching some essential WM_KEYDOWN messages when in focus, like Ctrl+C, Ctrl+V, etc. I've tried catching the WM_KEYDOWN message through WndProc, but the message is not propagating, so I guess the keyboard messages go from the inner container to the outer one, don't they?

The WM_KEYUP messages can be caught tho, but I'd prefer to be able to catch some of those messages on the KeyDown event. I'm aware I could make some low-level hook, but I'd like to avoid this workaround.

Well, if the WM_KEYDOWN message goes from the OCX to its top level container, I guess I'll have to treat those key combinations in the KeyUp event.

1
I'm relatively sure you can get all of this functionality using ApplicationCommands - msdn.microsoft.com/en-us/library/…Daniel May
My application is done using Windows Forms, not WPF (it was first built a couple of year ago). Anyway, I have my reservations about that method working, since even setting the owner form KeyPreview property to true, adding shortcuts to toolstrip menu items, etc cannot catch those special combinations.Neverbirth
Ctrl+C and Ctrl+V are the standard keystrokes for cut and paste. You really should be letting these keystrokes go to the window that has focus - the user is going to expect that they do.John Knoeller

1 Answers

0
votes

When your app is in focus you could register the crusial keys as hotkeys (RegisterHotkey API) and then unregister then as soon as your app goes out of focus.