获得汉字输入

在DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 函数中响应WM_IME_CHAR消息,wParam所存的就是汉字的编码。

代码如下:

LRESULT CGetChineseByIMEView::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    // TODO: Add your specialized code here and/or call the base class
    if (message == WM_IME_CHAR)
    {
        BYTE* byte = (BYTE*)&wParam;
        if (byte[1])
        {//输入汉字
            m_chineseWord[0] = byte[1];
            m_chineseWord[1] = byte[0];
            m_chineseWord[2] = 0;
        }
        else 
        {//输入字母
            m_chineseWord[0] = byte[0];
            m_chineseWord[1] = 0;
        }
} }

你可能感兴趣的:(汉字)