开发者

Getting Unicode character in WM_KEYDOWN

In an a开发者_Python百科pplication where I need to handle a lot of keys differently I want to handle all cases in WM_KEYDOWN and not use WM_CHAR at all. Is it possible to obtain the correct ASCII/UNICODE character from a sequence of WM_KEYDOWN supplied Virtual Keys instead of relying on the more regular TranslateMsg / WM_CHAR?

As an example: the application should be able to handle Shift-B in a totally different manner that pressing a regular B of CTRL-B.

Using MapVirtualKey, you do not use the state of the Shift, Control and Alt keys, or at least not that I can see.

As Leo Davidson answered: you can use the ToUnicode call to perform the VK -> Unicode conversion yourself.


WM_KEYDOWN deals with character codes, which basically means physical keys on the keyboard.

If you want to deal with unicode characters, handle WM_CHAR (16-bit Unicode chars, assuming your window itself is unicode) or WM_UNICHAR (32-bit Unicode chars) instead.

EDIT: If you want to do the conversion yourself, use the ToUnicode API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜