Fork me on GitHub

richedit禁用输入法的实现

            今天项目里遇到一个需求,密码输入框,不能输入中文,看了下主流的实现都是禁用输入法。

           

        HIMC  g_hIMC =NULL;       
richedit_ctrl_->AttachSetFocus([this](ui::EventArgs*){ g_hIMC = ImmAssociateContext(m_hWnd, NULL);//handle 为要禁用的窗口句柄 return true; }); richedit_ctrl_->AttachKillFocus([this](ui::EventArgs*){ if (g_hIMC) { ImmAssociateContext(m_hWnd, g_hIMC);//handle 为要启用的窗口句柄 } return true; });

          思路就是richedit获取到焦点的时候,禁用输入法,失去焦点的时候,恢复输入法。

posted @ 2020-06-17 18:38  烟波--钓徒  阅读(362)  评论(0编辑  收藏  举报