输入法编辑器(IME)程序设计(2)

有译的不妥的地方请你们指正,我随时更改:)
IME Window Class
The "IME" window class is a predefined system global class that defines the appearance and behavior of the standard IME windows. The class is similar to common control classes in that you create a window of this class by using the CreateWindowEx function. Like static controls, an IME window does not respond to user input by itself. Instead, it notifies the IME of user input actions and processes control messages sent to it by the IME or applications to carry out a response to the user action.
IME-aware applications sometimes create their own IME windows using the IME class. This allows the application to take advantage of the default processing of the IME window while having control of the positioning of the window.
 
IME”窗口类是一个预约义的系统全局类,它定义了标准IME窗口的外观与行为。在使用CreateWindowEx函数生成窗口时,这个类与普通的控件类很类似。像静态控件同样,IME窗口类本身不响应用户的输入。取而代之,它将用户的输入操做通知给IME而且处理由IME或者应用程序为了响应用户行为而发送给它的控制消息。
       IME感知类型的应用程序有时会应用IME类建立本身的IME窗口。这样当程序包含有窗口定位控件时就容许应用程序利用IME窗口的默认数据处理。
 
IME Messages
The system sends IME window messages to the window procedure of the application when certain events occur that affect the IME windows. For example, the system sends the WM_IME_SETCONTEXT message to the application when a window is activated. IME-unaware application pass these messages to the DefWindowProc function which sends them to the corresponding default IME window. IME-aware applications either process these messages or forward them to their own IME windows.
You can direct an IME window to carry out a command, such as change the position of composition window, by using the WM_IME_CONTROL message. The IME notifies the application about changes to the composition string by using the WM_IME_COMPOSITION message and about general changes to the status of the IME windows by sending the WM_IME_NOTIFY message.
 
       当某些能影响IME窗口的事件发生时,系统将向应用程序的窗口过程(window procedure)发送IME窗口消息。例如:当(应用程序的)窗口激活时系统将向应用程序发送WM_IME_SETCONTEXT消息。IME无感知类型的应用程序会把这些消息传递给DefWindowProc 函数,函数会把它们发送给相应的IME窗口。IME感知型的应用程序也会将这些消息或者把这些消息传递给本身的IME窗口。
       你能够直接控制IME窗口来执行命令,诸如能够用WM_IME_CONTROL消息来改变字母组合窗口(composition window,见上文)的位置。IME会使用WM_IME_COMPOSITION消息来通知应用程序关于字母组合字符串的变化,或用WM_IME_NOTIFY消息来通知关于IME窗口状态的常规改变。
 
Input Context
An input context is an internal structure, maintained by the IME, that contains information about the status of the IME and is used by IME windows. By default, the system creates and assigns an input context to each thread. Within the thread, this default input context is a shared resource and is associated with each newly created window.
 
       输入上下文(Input context)是一个内置结构,由IME来维护,它包含了IME窗口所使用的有关IME状态的信息。默认状况下,系统会为每个线程建立并指定一个输入上下文。在线程中,这个默认的输入上下文是一个共享资源,而且将会与每一个新建窗口关联。
 
To retrieve or set information in the IME, an application must first retrieve a handle to the input context associated with a specified window. You retrieve the handle by using the ImmGetContext function. You can use the retrieved handle in subsequent calls to the input method manager functions to retrieve and set IME values, such as the composition window style, the composition style, and the status window position. Once you have finished using the context, you must release it using the ImmReleaseContext function.
 
       要在IME中检索或设置信息,应用程序必须首先得到一个与指定窗口相关联的输入上下文的句柄。你能够经过ImmGetContext函数来得到这个句柄。在随后的输入法管理函数调用中,你能够使用这个句柄来检索和设置IME的值,诸如字母组合窗口的风格、字母组合的风格以及状态窗口的位置等。一旦你完成了上下文的使用,你就必须使用ImmReleaseContext函数来释放它。
 
Because the default input context is a shared resource, any changes you make to it apply to all windows in the thread. However, you can override this default behavior by creating and associating your own input context to one or more windows of the thread. The changes you make to your own input context apply only to the windows with which it is associated.
 
       由于默认的输入上下文是一个共享资源,你对它的任何改变都将应用于线程中的全部窗口。不过,你能够经过为线程中的一个或多个窗口生成并关联本身的输入上下文的方法来重写默认的行为。(不过,你也能够重写默认的行为,方法是为线程中的一个或多个窗口生成并关联本身输入上下文。)你对本身的输入上下文所作的改动将仅应用于与其相关的窗口上。
 
You can create an input context by using the ImmCreateContext function. To assign the context to a window, call the ImmAssociateContext function. This function returns a handle to the previously associated input context. If you have not associated an input context with the window before, the returned handle is for the default input context. Typically, you save this handle and later reassociate it with the window when you no longer want to use your own input context.
Once an input context is associated with a window, the system automatically selects that context when the window is activated and receives the input focus. The style and other information in the input context affects subsequent keyboard input for that window, determining whether and how the IME operates.
You must destroy any input context you create before terminating your application. First, you must remove the input context from any association it has with windows in the thread by using the ImmAssociateContext function. Then, call the ImmDestroyContext function.
 
       你能够用调用ImmCreateContext函数来建立一个输入上下文。要把输入上下文分配给一个窗口,须要调用ImmAssociateContext函数。这个函数将返回一个句柄,这个句柄是先前与窗口关联的输入上下文的句柄。若是先前没有输入上下文与些窗口相关联,函数将返回的句柄将是默认输入上下文(的句柄)。一般,你须要保存这个句柄(默认句柄),当你不想再使用本身的输入上下文时,再把它与窗口从新关联上。
       在一个输入上下文与一个窗口关联后,当窗口被激活时而且接受输入焦点时,系统会自动选择那个上下文。输入上下文中的格式(style)和其它信息会影响此窗口随后的键盘输入——决定IME是否和如何操做。
       在结束应用程序以前,你必须销毁全部你建立的输入上下文。首先,你必须使用ImmAssociateContext函数从线程中全部与之有关联的窗口上移除输入上下文。而后,调用ImmDestroyContext函数。

0javascript

收藏css

甜蜜的心情

175篇文章,294W+人气,47粉丝

Ctrl+Enter 发布html

发布java

取消jquery

推荐专栏更多

带你玩转高可用

前百度高级工程师的架构高可用实战

共15章 | 曹林华

¥51.00 522人订阅
负载均衡高手炼成记

高并发架构之路

共15章 | sery

¥51.00 601人订阅
基于Python的DevOps实战

自动化运维开发新概念

共20章 | 抚琴煮酒

¥51.00 572人订阅
网工2.0晋级攻略 ——零基础入门Python/Ansible

网络工程师2.0进阶指南

共30章 | 姜汁啤酒

¥51.00 2043人订阅
全局视角看大型园区网

路由交换+安全+无线+优化+运维

共40章 | 51CTOsummer

¥51.00 2595人订阅

扫一扫,领取大礼包

相关文章
相关标签/搜索