I'm using the standard hotkey control to allow user to specify a key combination for a certain action. However, it doesn't allow using the Return (Enter) key. Is there a way to allow it? My action is sort-of chat reply, so having a hotkey like Alt+Enter makes the most sense.
Asked
Active
Viewed 78 times
1 Answers
0
The only way would be to sub-class the control, since by default it rejects keys like VK_RETURN
.
Your sub-class would probably need to do two things:
- Handle the
WM_GETDLGCODE
message and returnDLGC_WANTMESSAGE
when the message indicates the enter key has been pressed - Handle the
WM_KEYDOWN
message when return is pressed, and manually set the hotkey in the control by sending it aHKM_SETHOTKEY
message.

Jonathan Potter
- 36,172
- 4
- 64
- 79