I have a combobox with items – hotkeys. I want to associate each one to a Win32 hotkey, e.g. F2 to VK_F2 and then call that one with RegisterHotkey. What’s the best way to do this? I looked up stuff and perhaps hexadecimal values could help, but it doesn’t say how to use them. Thanks.
I’m sorry I couldn’t provide more information but I don’t know what else should I include :/
You can use
TextToShortCut, and then decode the returnedTShortCutinto the required values forRegisterHotKey:TextToShortCutandShortCutToKeyare both defined in theMenusunit.YourHotKeyIDis a value between $0000-$BFFF you define that will be passed to your app in thewParamwhen you receive theWM_HOTKEYmessage.With all that being said, you should reconsider your choice of UI controls. If you use a
THotKey, the user can just press the key combination they want to use (instead of scrolling through a list). You can then use theTHotKey.HotKeyin place of theShortCutvariable in the sample code (you can pass it directly toShortCutToKey, and eliminate theShortCutvariable entirely):And, in anticipation of your soon-to-come comment :), how to catch and handle the
WM_HOTKEYmessage and how to handle multiple hotkeys you have registered should be a new question. This one was specifically about a combobox and a hotkey; how to handle the hotkey being pressed is totally different.