我认为你应该处理WM_IME_CHAR消息,而不是WM_CHAR消息WM_IME_CHAR The WM_IME_CHAR message is sent to an application when the IME gets a character of the conversion result. Unlike the WM_CHAR message, this message can include double-byte as well as single-byte character values. // for double-byte characters: chCharCode1 = (char) wParam & 0xff; chCharCode2 = (char) wParam >> 8; // for Unicode: chCharCode1 = (WORD) wParam; lKeyData = lParam;
nChar就是输入的一个CHAR型变量,汉字就是2个CHAR的组合。
The WM_IME_CHAR message is sent to an application when the IME gets a character of the conversion result. Unlike the WM_CHAR message, this message can include double-byte as well as single-byte character values. // for double-byte characters:
chCharCode1 = (char) wParam & 0xff;
chCharCode2 = (char) wParam >> 8;
// for Unicode:
chCharCode1 = (WORD) wParam;
lKeyData = lParam;
以上的各位都说过了, 但是我觉得还是 WM_IME_CHAR 方便些且专业些.
//消息映射
ON_MESSAGE( WM_IME_CHAR, OnImeChar ) // 消息处理函数:参数的意义参考MSDN
afx_msg LRESULT OnImeChar(WPARAM wParam, LPARAM lParam );