MFC 禁用输入法

#include <Imm.h>

HIMC m_hImc;    // 全局或者成员变量

// Function for Disabling IME
void CMyDialog::DisableIME()
{
    HWND hWnd = GetDlgItem(IDC_EDIT1)->m_hWnd;
    if (hWnd && IsWindow(hWnd))
    {
        // Get input context for backup. 
        m_hImc = ImmGetContext(hWnd);

        // Remove association the testing 
        if (m_hImc)
            ImmAssociateContext(hWnd, NULL);

        // Release input context
        ImmReleaseContext(hWnd, m_hImc);
        ::SetFocus(hWnd);
    }
}

 

posted @ 2016-10-27 10:35  程序员大叔  阅读(1697)  评论(0编辑  收藏  举报