windows 程序禁用中文輸入法


windows 程序禁用中文輸入法方法:
1、添加windows頭文件及dll文件

//輸入法相關  
#include <imm.h>  
#pragma comment (lib ,"imm32.lib") 

//2、禁用:
HIMC g_hIMC = NULL;//g_hIMC 用於恢復時使用  
g_hIMC = ImmAssociateContext(handle, NULL);//handle 為要禁用的窗口句柄

//3、啟用
ImmAssociateContext(handle, g_hIMC);//handle 為要啟用的窗口句柄 

注意:如果是mfc程序,最好在InitInstance() 中加入 ImmDisableIME(GetCurrentThreadId());

 

windows8或以后版本設置全局輸入法:

HKL m_hKeyLayout = GetKeyboardLayout(GetCurrentThreadId())獲取當前布局

//設置全局輸入法為英文
LoadKeyboardLayout(_T("0x0409"), KLF_ACTIVATE);

//英文不再使用,切換回來

ActivateKeyboardLayout(m_hKeyLayout , 0);

 

 

原文鏈接:https://blog.csdn.net/hellokandy/article/details/72902715

原文鏈接:https://zhidao.baidu.com/question/1670370529950015427.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM