输入法编辑器(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 函数。

本文出自 “上善若水 润物无声” 博客,转载请与作者联系!

分享至
一键收藏,随时查看,分享好友!
0人
了这篇文章
类别: Windows开发┆阅读( 0)┆评论( 0) ┆ 返回博主首页┆ 返回博客首页
上一篇 输入法编辑器(IME)程序设计(1) 下一篇 五笔王朝的终结

相关文章

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

职位推荐

  • 中高级前端工程师
  • PHP开发工程师
  • 后端开发
  • 前端开发工程师/前端设计/网站制作
  • 高级PHP开发工程师

文章评论

 
 

发表评论            

昵  称:
登录  快速注册
验证码:

点击图片可刷新验证码请点击后输入验证码博客过2级,无需填写验证码

内  容:

同时赞一个

每日博报 精彩不止一点关闭

你可能感兴趣的:(输入法,程序设计)