0

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.

riv
  • 6,846
  • 2
  • 34
  • 63

1 Answers1

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 return DLGC_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 a HKM_SETHOTKEY message.
Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79