MFC編輯框禁用輸入法方法
添加頭文件
#include <Imm.h>
添加依賴庫
#pragma comment ( lib, "imm32.lib" )
添加全局變量
HIMC m_hImc; // 全局或者成員變量
申明方法
void DisableIME();
定義方法、
void XXXDlg::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);
}
}
最後在初始化函數OnInitDialog()中添加禁用方法
DisableIME()