Windows IME (一)

Input Method Editor

An input method editor (IME) is a program that allows computer users to enter complex characters and symbols, such as Japanese Kanji characters, by using a standard keyboard.

           

输入法编辑器(IME)是一个程序,这个程序允许计算机用户使用标准键盘就能输入复杂的字符与符号,例如日文中的汉字(严重反对!中文是世界上使用人口最多的文字,这里应该是中文才好!)字符。

 

This overview describes the IME and explains how to use the input method manager functions to create and manage IME windows.

 

本预览描述了IME,并且解释说明了如何使用输入法管理程序(IMM)函数来创建和管理IME窗口。

¨         关于输入法编辑器

¨         使用输入法编辑器

¨         输入法编辑器参考

 

About Input Method Editor

The input method editor relieves users of the need to remember all possible character values. Instead, the IME monitors the user's keystrokes, anticipates the characters the user may want, and presents a list of candidate characters from which to choose.

 

            输入法编辑器减轻了用户记住所有可能字符值的需要,取而代之,IME监控用户的击键、预见用户可能期望的字符,并且提供一个可选字符的列表,用户可以从中选择想要的字符。

 

By default, the IME provides an IME window through which users enter keystrokes and view and select candidates. Applications can use the input method manager (IMM) functions and messages to create and manage their own IME windows, providing a custom interface while using the conversion capabilities of the IME.

 

            默认情况下,IME提供了一个IME窗口,通过这个窗口,用户可以用键盘输入并且查看和选择想要的字符。应用程序可以使用输入法管理器(IMM)函数和消息来创建并且管理其自己的IME窗口(比如QQ里是五笔而Word里却是拼音),并在使用IME的转换功能时提供一个自定义接口(不太明白)。

 

IMM is only enabled on East Asian (Chinese, Japanese, Korean) localized Windows. On these systems, call GetSystemMetrics with SM_DBCSENABLED to determine if IMM is enabled. Note that Windows 2000 provides full-featured IME support in all localized language versions, however, that IMM is enabled only when an Asian language pack is installed. An IME-enabled application can callGetSystemMetrics with SM_IMMENABLED to determine if IMM is enabled.

 

            IMM只在东亚(中国,日本,韩国)本地化的Windows中才可用。在这些系统中,以SM_DBCSENABLED消息调用GetSystemMetrics函数来确定IMM是否可用。注意,Windows 2000在所有本地化版本中都提供了全功能的IME支持,然而仅在安装了亚洲语言包的时候IMM才可用。一个IME-enabled(IME可用)的程序会以SM_IMMENABLED调用GetSystemMetrics函数来确定IMM是否可用。

 

Status, Composition, and Candidates Windows

The status, composition, and candidates windows form the user interface for the IME. The status window indicates that the IME is open and provides the user the means to set the conversion modes. The composition window appears when the user enters text and, depending on the conversion mode, either displays the text as entered or displays converted text. The candidates window appears in conjunction with the composition window. It contains a list of "candidates" (alternative characters) for the selected character or characters in the composition window. The user can scroll through the candidates list and select the desired characters, then return to the composition window. The user can compose the desired text in this way until the composition string is finalized and the window is closed. The IME sends the composed characters to the application in the form of WM_IME_CHAR or WM_IME_COMPOSITION/GCS_RESULT messages. If the application does not process these messages, the DefWindowProc function translates them into one or more WM_CHARmessages.

 

            状态窗口、字母组合窗口和列选窗口构成了IME的用户界面。状态窗口指示出IME处于开启状态并且提供给用户设置转换模式的方法。字母组合窗口会在用户输入字符的时候出现,其形式基于转换模式,同时显示已经输入的字母或者是已经转换了的字符。(conversion mode转换模式=输入法,比如微软拼音、五笔字型……其实不同的输入法的本质是不同的转换规则。)列选窗口会紧挨着字母组合窗口显示。它包含了一个由“候选条目”构成的列表,此列表匹配选中字符或者是字母组合窗口中的字符。用户可以滚动列选窗口并且选择想要的字符,然后(焦点)返回到字母组合窗口。借此用户可以组合想要的文本直到字符组合成的字符串结束,窗口会关闭。IME将使用WM_IME_CHAR或 WM_IME_COMPOSITION/GCS_RESULT消息把组合好的字符发送给窗体中的应用程序。如果应用程序没有处理这些消息,DefWindowProc函数会把它们翻译成一条或多条WM_CHAR消息。

 

By default, the system automatically creates and manages status, composition, and candidates windows for all windows that require text input. For many applications, this default processing is sufficient. These applications rely entirely on the system for IME support and are said to be IME-unaware because they are unaware of the many tasks the system carries out to manage the IME windows.

 

            默认情况下,系统会为所有要求输入文本的窗口自动生成并管理状态窗口、字母组合窗口和列选窗口。对于许多程序,这一默认处理已经足够了。这些完全依赖于系统提供IME支持的应用程序称为IME-unaware(IME无感知)程序,原因在于它们对系统为管理IME窗口所完成的诸多任务毫无感觉。

 

An IME-aware application, on the other hand, participates in the creation and management of IME windows. Such applications control the operation, position, and appearance of the default windows by sending messages to and by intercepting and processing messages intended for these windows. In some cases, applications create their own IME windows and provide complete processing for their custom status, composition and candidates windows.

 

            相反,一个IME-aware(IME感知)程序会参与IME窗口的创建与管理。例如程序可能通过发送或截取消息并且有目的地对这些(IME)窗口消息进行处理,来控制默认(IME)窗口的选项、位置和外观。有些情况下,应用程序会创建它们自己的IME窗口并且对其自定义的状态、字母组合和列选窗口提供完全的控制处理。

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_SETCONTEXTmessage 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 theImmGetContext 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 theImmAssociateContext function. Then, call the ImmDestroyContext function.

 

            你可以用调用ImmCreateContext函数来创建一个输入上下文。要把输入上下文分配给一个窗口,需要调用ImmAssociateContext函数。这个函数将返回一个句柄,这个句柄是先前与窗口关联的输入上下文的句柄。如果先前没有输入上下文与些窗口相关联,函数将返回的句柄将是默认输入上下文(的句柄)。通常,你需要保存这个句柄(默认句柄),当你不想再使用自己的输入上下文时,再把它与窗口重新关联上。

            在一个输入上下文与一个窗口关联后,当窗口被激活时并且接受输入焦点时,系统会自动选择那个上下文。输入上下文中的格式(style)和其它信息会影响此窗口随后的键盘输入——决定IME是否和如何操作。

            在结束应用程序之前,你必须销毁所有你创建的输入上下文。首先,你必须使用ImmAssociateContext函数从线程中所有与之有关联的窗口上移除输入上下文。然后,调用ImmDestroyContext函数。


转载地址:http://blog.sina.com.cn/s/blog_65b22bb50100htu4.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值