Convert hotkey in CHotKeyCtrl from virtual code to string and backward
I have CHotKeyCtrl
and I can get virtual Key Code and modifiers from it. I also can call CHotKeyCtrl::GetHotKeyName
to get string view of this hotkey - I can show this string to user and store it in开发者_如何学运维 my XML config file. But how to convert this string backward to virtual key code and modifiers? I do not want to save in XML just virtual keycode and midifiers in WORD
form (it's not very informative).
To my knowledge, there is no support out of the box to convert a hot key name into a virtual key code + modifiers pair, mainly because GetHotKeyName() returns a localized name. That name comes from the keyboard driver and will vary from one Windows installation to the other.
Since WM_SETHOTKEY takes a virtual key code and its modifiers, packed into a WPARAM
, you can build that value and store it in your XML settings in order to avoid using two elements / attributes. You can also include the hot key name for easier reading, but storing only that name will not give you the information required to send WM_SETHOTKEY
afterwards.
精彩评论