views:

102

answers:

2

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.

A: 

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.

danbystrom
A: 

Well, I guess I'll treat the key combinations caught by the third party OCX on the key up event instead.

EDIT: Didn't see your message danbystrom, sorry. That method would be like making a low level hook, and I've considered both methods when found this problem, but I'm not sure of using it, what if the program fails to unhook or unregister the hotkey on some case? dunno, since the application is composed by a lot of parts I wouldn't want to trap those main shortcuts, but maybe that would not be possible and activate/deactivate/setfocus/killfocus won't misadvice me.

Neverbirth