Introduction to the input method

zhaozj2021-02-08  322

This is a very early thing, huh, huh, maybe someone will use it!

The input method editorial input method editor (IME) is to allow users to enter complex letters and symbols, such as Japanese Chinese characters. This document describes the method of creating and managing the IME (Input Method Editor) window. 1. Introduction to the input method Editor IME is not a character value that the user may use, but monitor the user's button to expect the user who may need, and provide an alternative character list for users to select the required character. By default, IME provides users with an IME window that can typure and select Alternate characters. The Win32 program can create its own IME window using the Custom Interface provided by the IME transform function. IMM can be activated only on Windows95 / 98 and WindowsNT4.0 / 3.5 / platform in the Far East. Call GetSystemMetrics with SM_DBCSenabled on these systems to determine if IMM is activated. Windows2000 provides IME support for all of the features for all languages. However, it is important to note that when the Asian language package is installed, the IMM can be activated, and a program that activates IMM calls GetSystemMetrics with SM_IMMENABLED to determine whether the current IMM is active. 1.1 Status, record words, and alternative window user interfaces provide status, record words, and alternative windows for IME. The status window indication IME is turned on and provides a way to set the conversion mode; when the user enters text, the video window is bomb, depending on the conversion mode display input text or converted. The alternative window is also appearing together, including the alternative character or characters in the recorded window, the user can scroll out the option list to select the desired character, and then return to the video window. Users can use this method to enter the desired text until the end of the string is completed and the window is closed. In the form of a WM_IME_CHAR or WM_IME_COMPOSITION / GCS_RESULT message, the IME is sent to the entry character. If the program does not process these messages, the DEFWINDOWPROC function translates them into one or more WM_CHAR messages. By default, the system automatically creates and manages status, record words, and alternative windows for all windows you need text. This default process is efficient to many programs. These programs are completely dependent on the system's support and is called "IME-unaWare". This is because they ignore many of the tasks of the system management IME window. Companies, a "IME-aware" program must participate in the creation and management of IME windows. Such programs control the operation, location, and appearance of the window by passing, intercepting, and processing a message to the default window. In some cases, the program can create its own IME window and provide a complete processing method for its own customization, record words, and alternative windows. 1.2 IME Window Class "IME" window class is a predefined definition standard IME window behavior and an appearance system global class. The window class is similar to the general control class. In this class, you can create this class with the CREATEWINDOWEX function. If the static control IME window does not own entered the user input, it notifies the user to enter behavioral IME and use IME or respond to user behavior. Program to transfer process control messages. The Ime-Aware program sometimes creates its own IME window with the IME class. This allows programs to utilize the default IME window process and window location controls. 1.3 IME Messages When an event occurs, the system sends an IME window message to the program window program to affect the IME window. For example, when a window is activated, the system sends a WM_IME_SETCONTEXT message to the application. The IME-UNAWAR program transmits these messages to the DefWindowProc function, the latter sent the message to the corresponding default IME window.

You can use the WM_IME_CONTROL message to guide the IME window execution command, such as changing the location of the recorded window; IME uses the WM_IME_COMPSISITION message notification program to record the change in strings; send out the general change of the WM_IME_NOTIFY message notification program IME window status. 1.4 Input Context Enter the context is the internal structure supported by IME, including the IME status and the information used by the IME window. By default, the system creates and assigns an input context for each thread, and this default input context is a shared resource and is connected to each new window. To retrieve or set information in the IME, the application must first retrieve it, connect to the handle of the specified window input context, and call the ImmgetContext function to complete the search. Subsequently, the input method manager function retrieves and sets the IME value, such as recorded window style, and status window position. Once used in the context, you must release it with the ImmreleaseContext function. Since the default context is a shared resource, it will react to all windows of the thread. However, you can create and associate your own window to one or more threads of the window, the default behavior is over. Thereafter, only the window associated with your own input context will change. You can create an input context by using the ImmcreateContext function. In order to give the Window, the ImmaSociateContext function can be called to return a handle to the previous associated input context. If the input context is previously associated with the window, the return handle is the default input context. Typically, this handle can be saved, and the handle is reconnected from the window when you no longer use your own input context. Once the context is entered with the window connection, the system automatically selects when the window is activated and the context of the input focus. Entering the context style and other information will affect the keyboard input behind the window and decide how to perform IME operations. Before ending the application, you must eliminate the input context created by users yourself. First, you must remove any input context that is associated with the ImmaSosciateContext function in the thread. Subsequently, call the ImmdestroyContext function. 1.5, entering a string entry string is the current text that is entered into the window. That is, IME is converted to the text of the final character. Each entry string consists of one or more Clauses, where clauses is the minimum combination of the IME to convert to the final character. You can call the immsetCompationstring and ImmgetCompositionString function to get and set up a string. When the user enters the window into the text, the IME traces the status of the window, including attribute information, CLAUSE information, typing information, and cursor position. You can retrieve the entry status with the ImmgetCompationstring function. In an attribute information array, all characters in a CLAUSE must have the same properties. The attribute information is an 8-bit value array that specifies the status of the character in the entry string. Each byte in the string corresponds to a value, such as any double-byte character in the string, by one byte, respectively, with one byte, respectively. For each value in the array, you can press the table to combine 1 bits to 3-bit values. Value Configuration ATTR_INPUT Enter characters converted by IME. Attr_input_error character is incorrect and cannot be converted by IME. For example, some consonants cannot be placed together. Attr_target_converted The character has been converted, the user has selected this character and the IME industry has converted. Attr_converted has been converted characters. ATTR_TARGET_NOTCONVERTED is being converted, the user has selected this character but IME has not converted it. Attr_fixedConvertED will not be converted characters, IME does not convert these characters. All other values ​​are retained.

In Japanese, any unconverted characters with attr_input attributes are a parity name, a film fake name or alphanumeric character. Han Wen, this character is a Hangeul character that is not converted by IME. In the traditional Chinese, each IME has a restricted character in a certain range. The CLAUSE information is a 32-bit value array to specify the location of the CLAUSE in the window. Each CLAUSE has a value, and the last value is used to specify the length of the string. Each value of the array specifies the number offset from the start to CLAUSE from the string. Since the first CLAUSE always starts from the serial head, the first value is always zero. Such as: A string has two clauses, then the CLAUSE information has 3 values: the first value is zero, the second value is the offset of the second CLAUSE, and the third value is a string length. For Unicode, the length of the CLAUSE is the size in the Unicode character. Typing Information is a string of NULL that represents the keyboard in the keyboard. Cursor Position is a value indicating the cursor position associated with the character in the entry string. This value uses bytes to represent the offset from the serial head. If this value is zero, the cursor is in front of the first character in the string. If the value is the length of the string, the cursor is next to the last character in the string. If the value is -1, there is no cursor. For Unicode Location and Length In the Unicode Character, the IMMSetCompationstring function can be used to set the entry string or entry state element. To ensure that the window update is based on these changes, the function allows the window to transfer the notification message, set an application entry state element combination, which can set the Notify parameter for all the calls of the last call to False, so Entering the window only generates a notification message. Finally, the editing control supports two messages to change the entry string handle of the IME. 1.6 Alternative list Alternative list is a CandidateList structure. This structure consists of a character string of the specified string or a string selected from it, can be retrieved with an ImmgetCandIdateListCount and an ImmgetCandIdateList function to retrieve alternative properties. 1.7 Hot key heat keys allow users to quickly change the IME input mode or switch to other IMEs. Although the program does not increase the thermal key to the system, use the ImmsimulateHotKey function to start the same line as a hotkey. The HEX to Unicode IME also allows the hexadecimal characters and the interpretation of Unicode characters. 1.8 HEX to Unicode IME Rich Edit 3.0 supports Hex To Unicode IME, allowing users to use one or two hot bonds to interchange between hexadecimal characters and Unicode characters. In the first method, the user typed the hexadecimal code and pressed Alt X. The IME uses Unicode characters before the insertion point is replaced by hexadecimal numbers. If the current font does not support the character code, the appropriate font support is selected. The Unicode becomes hexadecimal, then press SHIFT ALT X. Special, allowing determination of characters indicated by the Lost Symbols indicator. If the hexadecimal code is followed by legal (non-character) hexadecimal characters, you must choose the specific number you want to change before pressing Alt X. The example of this method is that Alt X is sometimes used as a key combination of "exit" commands, such as in Microsoft's Office, as an option for the File menu. The second method involves digital PAD. Here, the user enters the ALT NUM PAD (value of the value of 255) to enter Unicode characters with a decimal value. This method is not useful as the first method, because it is not possible to see the number of hexadecimal numbers. At the same time, in addition to re-entering anywise, the error cannot be revised.

2, input method editor application 2.1 Processing WM-IME-Composition Message Processing WM_IME_Composition Message Program Test LPARAM Parameters The number of bits and calls the imgetCompositionString function retrieves the indicator string or data. The following example checks the result string, assigns enough memory to the string and retrieves the result string from the IME. Himc himc; hglobal hster; lpstr lpstr; case wm_ime_composition: if (lparam & gcs_resultstr) {HIMC = ImmgetContext (hwnd);

IF (! HiMC) myerror (Error_NullContext);

// get the size of the result string. Dwsize = immgetCompositionString (HIMC, GCS_RESULTSTR, NULL, 0);

// Increase Buffer Size for Null Terminator, // Maybe It Is in Unicode Dwsize = SizeOf (Wchar);

HSTR = Globalalloc (GHND, DWSIZE); if (hstr == null) MyError (Error_GlobalAlloc);

LPSTR = Globalock (HSTR); if (lpstr == null) MyError (Error_Globalock);

// Get The Result strings That IS generated by IME INTO LPSTR. ImmgetCompositionstring (HIMC, GCS_RESULTSTR, LPSTR, DWSIZE); ImmreeleaseContext (HWND, HIMC);

// Add this string inTo Text Buffer of Application

转载请注明原文地址:https://www.9cbs.com/read-1012.html

New Post(0)