admin管理员组文章数量:1657960
最近又开始研究输入法的bug了。。。真倒霉。。。这次是为了解决在微软拼音和谷歌拼音输入法开启的时候,Dynamic input输入的第一个数字(比如圆的直径)会丢失,这肯定是来自中国客户的抱怨,而且貌似是个大客户,上头催得紧,得罪不起,咋办,只能研究了呀!
我们之前的逻辑是这样的:
1. 在View里面监视KeyDown事件,假如收到的Char是VK_PROCESSKEY,那么就认为这是一个输入法字符,会触发输入法的Composition,处理的方法就是:
a)把事件标记成已处理,这样就屏蔽了WM_CHAR消息;
b)显示一个空的输入框~(对于用户来说,看到的是一个空的输入框,外加一个输入法自己显示的候选词窗口)。 对于普通的中文输入法来说(搜狗,QQ),这个是完美的,但是微软和谷歌则不一样,在输入法开启后,就算你输入的是数字!他发送的也是VK_PROCESSKEY消息,而且,不会出现候选词窗口,那么用户看到的就是一个空的输入框了(因为WM_CHAR被屏蔽了)。。。
2. 那么解决方案是什么呢?。。。最简单的话,就是判断,这是不是一个真正的IME Char,或者说这个字符到底会不会触发IME Composition窗口!假如不会,那么就继续发送WM_CHAR消息,于是就有了这么如下代码:
bool
CAcDynInput::onExternalKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags, bool& bWantOnChar)
{
// IME
if (nChar == VK_PROCESSKEY) {
bool bImeEnterCompositionMode = true;
// DID#1488000. The origin logic is that if nChar == VK_PROCESSKEY,
// we assume it will turn IME into Composition Mode and show the candidate
// words in IME's composition floating window. So we suppress the
// WM_CHAR message and show an empty Dynamic Input Box and user
// will see the IME compostion window near by. But actually, for Microsoft
// Pinyin IME and Google Pinyin IME, if you type number '1', though the nChar
// is still VK_PROCESSKEY, but it won't enter IME composition mode. As a result,
// the char is lost (bcz we suppress WM_CHAR message) and user only
版权声明:本文标题:VC++在Win7和Win8系统下获得百度输入法的名字 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1729801549a1212968.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论