windows 你如何使用输入法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/434048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:48:37  来源:igfitidea点击:

how do you use IME?

windowswinapiime

提问by CiNN

I want to make a control that handles user input, so I want to be able to handle different keyboards, and one of the ways is using IME.

我想做一个处理用户输入的控件,所以我希望能够处理不同的键盘,其中一种方法是使用 IME。

If you don't handle it, there is a floating window that appears when you have IME active (for example japanese writing active). I found the messages that needs to be taken care of, but I don't know how to send the keys I'm trapping to the IME and when do I get a valid converted char.

如果您不处理它,当您启用 IME(例如启用日语书写)时,会出现一个浮动窗口。我找到了需要处理的消息,但我不知道如何将我捕获的密钥发送到 IME,以及何时才能获得有效的转换字符。

回答by Leftium

I'm a Microsoft SDE that used to maintain the (Windows and Office) Korean IME for a while...

我是 Microsoft SDE,曾经维护(Windows 和 Office)韩语 IME 一段时间...

Unfortunately the best IME API documentation is provided by non-Microsoft sites:

不幸的是,最好的 IME API 文档是由非 Microsoft 站点提供的:



Here is the official Microsoft documentation: Input Method Manager (MSDN)

这是微软官方文档:输入法管理器(MSDN)

There is also a new, more advanced IME based on the Text Services Framework (TSF) that Microsoft would prefer you to use, but it's even more complicated and the old API is emulated pretty well. If you don't need any of the advanced features (like input via tablet/voice recognition/fancier IME/etc) then using the old API is sufficient.

还有一个基于文本服务框架 (TSF) 的新的、更高级的 IME,Microsoft 希望您使用它,但它更加复杂,并且可以很好地模拟旧 API。如果您不需要任何高级功能(例如通过平板电脑/语音识别/高级 IME/等输入),那么使用旧 API 就足够了。

The best documentation on the Text Services Framework is the TSF Aware Blogwritten by another Microsoft dev. Eric Brown may even personally answer your questions if you go this route.

关于文本服务框架的最佳文档是由另一位 Microsoft 开发人员编写的TSF Aware 博客。如果你走这条路,埃里克·布朗甚至可以亲自回答你的问题。

Here is the official Microsoft documentation for TSF: Text Services Framework (MSDN)

这是 TSF 的官方 Microsoft 文档:文本服务框架 (MSDN)

One feature of TSF you may find useful is the ability to suppress rendering of the IME (needed for full screen games that need to render the IME themselves, for example). Simply tell TSF that your app will render the IME GUI, then implement an empty rendering method: UILess Mode Overview (MSDN)

您可能会发现 TSF 的一项有用功能是能够抑制 IME 的呈现(例如,需要自己呈现 IME 的全屏游戏)。只需告诉 TSF 您的应用程序将呈现 IME GUI,然后实现一个空的呈现方法:UILess Mode Overview (MSDN)

回答by Andy

I don't think that you want to supress an IME from being displayed. I've never used one other than for testing, but it's my understanding that an IME is the expected/default way of entering non-English characters using an English keyboard.

我认为您不想抑制 IME 的显示。除了用于测试之外,我从未使用过其他方法,但据我所知,IME 是使用英文键盘输入非英文字符的预期/默认方式。

If you are writing a control and want to fully support an IME, I think the two options that you have are to respond to the various Windows messages (like WM_IME_START_COMPOSITION, WM_IME_COMPOSITION, etc.) or use Text Services Framework (TSF). It's my understanding that TSF is the future, and in Vista and Windows 7 all of the IME code is based off of TSF, with the Windows messages still there for compatibility with old programs.

如果您正在编写控件并希望完全支持 IME,我认为您拥有的两个选项是响应各种 Windows 消息(如 WM_IME_START_COMPOSITION、WM_IME_COMPOSITION 等)或使用文本服务框架 (TSF)。我的理解是 TSF 是未来,在 Vista 和 Windows 7 中,所有 IME 代码都基于 TSF,Windows 消息仍然存在以与旧程序兼容。