|
|

楼主 |
发表于 2007-3-9 11:36:00
|
显示全部楼层
Re:如何处理DirectInput独占模式下的中文输入问题?
在键盘非独占模式下,按下键盘时,在程序收到WM_KEYDOWN消息,还将收到WM_CHAR消息,得到按键对应的字符,包括Backspace等一些非显示字符。这下所有文字输入问题都不再使用DirectInput了。
但没有使用独占模式,按键时,系统自动产生很多没有用的消息,虽然对程序的运行效率没有多大影响,可心里总是觉得不太舒服,而且非独占模式下,所有的windows热键都是有效的,我不希望这样。
今天突然想到,是否可以使用ImmSetCompositionString函数来实现文字编码的输入。
有没有人研究过?讨论一下吧,这个函数我还不太会用,也没有找到实例。
MSDN的说明是这样的,请高人解释一下:
The ImmSetCompositionString function sets the characters, attributes, and clauses of the composition and reading strings.
BOOL ImmSetCompositionString(
HIMC hIMC,
DWORD dwIndex,
LPVOID lpComp,
DWORD dwCompLen,
LPVOID lpRead,
DWORD dwReadLen
);
Parameters
hIMC
[in] Handle to the input context.
dwIndex
[in] Specifies the type of information to set. This parameter can be one of the following values. Value Meaning
SCS_SETSTR Sets the composition string, the reading string, or both. At least one of the lpComp and lpRead parameters must point to a valid string. If either string is too long, the IME truncates it.
SCS_CHANGEATTR Sets attributes for the composition string, the reading string, or both. At least one of the lpComp and lpRead parameters must point to a valid attribute array.
SCS_CHANGECLAUSE Sets the clause information for the composition string, the reading string, or both. At least one of the lpComp and lpRead parameters must point to a valid clause information array.
SCS_SETRECONVERTSTRING Windows 98/Me, Windows 2000/XP: Asks IME to reconvert the string by a specified RECONVERTSTRING structure.
SCS_QUERYRECONVERTSTRING Windows 98/Me, Windows 2000/XP: Asks IME to adjust the RECONVERTSTRING structure. Then the application can pass the adjusted RECONVERTSTRING structure into this API with SCS_SETRECONVERTSTRING. IME will not generate any WM_IME_COMPOSITION messages.
lpComp
[in] Pointer to a buffer containing the information to set for the composition string. The information is as specified by the dwIndex value.
dwCompLen
[in] Specifies the size, in bytes, of the information buffer for the composition string. This is true even if SCS_SETSTR is specified and the buffer contains a Unicode string.
lpRead
[in] Pointer to a buffer containing the information to set for the reading string. The information is as specified by the dwIndex value.
dwReadLen
[in] Specifies the size, in bytes, of the information buffer for the reading string. The size is in bytes even if SCS_SETSTR is specified and the buffer contains a Unicode string.
|
|