輸入法編輯器(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篇文章,286W+人氣,42粉絲

Ctrl+Enter 發佈html

發佈java

取消python

推薦專欄更多

帶你玩轉高可用

前百度高級工程師的架構高可用實戰

共15章 | 曹林華

¥51.00 502人訂閱
負載均衡高手煉成記

高併發架構之路

共15章 | sery

¥51.00 564人訂閱
基於Python的DevOps實戰

自動化運維開發新概念

共20章 | 撫琴煮酒

¥51.00 509人訂閱
網工2.0晉級攻略 ——零基礎入門Python/Ansible

網絡工程師2.0進階指南

共30章 | 薑汁啤酒

¥51.00 1916人訂閱
全局視角看大型園區網

路由交換+安全+無線+優化+運維

共40章 | 51CTOsummer

¥51.00 2313人訂閱

掃一掃,領取大禮包jquery

0git

分享
水之真諦
相關文章
相關標籤/搜索