What is the correct, modern way to handle arbitrary text input in a custom control on Windows? WM_CHAR? IMM? TSF?

▼魔方 西西 提交于 2019-12-03 16:31:28

The TSF API is a superset of the IMM API. It's also newer than IMM, and is the current, modern way to handle international text input (as well as other input mechanisms like handwriting and speech).

If you use the TSF API, text appears via the API instead of windows messages (so the issue of which message is irrelevant).

The On-Screen keyboard is handled automatically, and you shouldn't have to worry about it. (The entire purpose of TSF is to make your app independent of input source.)

TSF can support UTF-8, but it's a bit of a pain; you need to mark the extension characters as hidden. You would be much better off with UTF-16, which is TSF's default API.

The best example I know of on how to add TSF support to an existing edit control is still the article I wrote back in July 2007.

Input can still arrive via WM_CHAR (if the current input profile is a keyboard layout, for example), so you need to implement this as well; typically, though, you can handle WM_CHAR messages by calling into your ITextStoreACP::InsertTextAtSelection implementation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!