I have a dialog box that allows users to set hotkeys for use in a 3d program on windows. I’m using CHotKeyCtrl, which is pretty good, but doesn’t handle some keys that the users would like to use – specifically, tab and space.
The hotkey handling is smart enough to be able to fire on those keys, I just need a UI to let them be set. A control similar to CHotKeyCtrl would be ideal, but other workarounds are also appreciated.
One workarounds option would be to use a stock standard edit control with a message hook function.
This would allow you to trap the keyboard WM_KEYDOWN messages sent to that edit control.
The hook function would look something like this:
The hook can then be attached to edit control when the edit control gets focus as follows:
and removed when the edit control when looses focus as follows:
Using this approach every key press will be sent to the hook, provided the edit control has focus.