IME input method programming

xiaoxiao2021-03-30  207

Basic principle of Chinese character input method under Windows9X system

The Chinese character input method under the Windows system is actually converted into a national or Chinese string in a certain coding rule, enters the destination. Because the application is different, the user cannot design the conversion program itself, so the Chinese characters will naturally fall into Windows system management.

First, the relationship between input method and system

Keyboard event application

| | |

Windows User.exe

|

Input Manager

|

Input

After the system's keyboard event has Windows User.exe software, user.exe is transmitted to the input method in the input method in the input method in the Input Method Manager, the Manager, the Manager, the INPUT METHOD MANAGER, the input method. According to the user-coded dictionary, the translation keyboard event is the corresponding Chinese character (or Chinese character string), and then reverse in User.exe, user.exe will pass the translated keyboard event to the currently running application, to complete the Chinese character input of.

Second, the composition of the Chinese character input method

The name of the Chinese character input method in the Microsoft Windows 9x system is "Input Method Editor", referred to as IME, the program name of the input method is: *. IME, the data file name address * .mb, ie, the normally input method coding table (dictionary).

In fact, IME file is a dynamic connection library program (DLL), which is different from DLL files, but the name is different.

The general Chinese character input method consists of three windows:

Status Windows - Displays the current input method (Chinese or English information);

Code Enter Windows - Displays the current hit button;

Chinese character selection window (Candidates Windows) listing all Chinese characters (strings) currently available for users to choose or query.

The above three windows are managed by the basic user interface function.

Now we use dumpbin.exe to open Microsoft's Pinyin input method (windows / system / winpy.ime) to see what it makes up (here a Windows98 is an example, and assumes that the Windows system is installed under C: disk):

C: / dumpbin c: /windows/system/winpy.ime

Microsoft (R) Coff Binary File Dumper Version 6.00.8168

Copyright (c) Microsoft Corp 1992-1998. All Rights Reserved.

Dump of file winpy.ime

FILE TYPE: DLL // IME actual DLL program

Section Contains the Following Exports for WinPy.ime

0 Characteristics

34A37323 Time Date Stamp Fri Dec 26 17:04:35 1997

0.00 Version

1 ORDINAL BASE

19 Number of functions / / total 19 functions

19 Number of Names // Corresponds to 19 names

Ordinal Hint Rva Name

1 0 0000A010 CANDWNDPROC // "Select Chinese Character Window" Registration Function

2 1 0000E750 compWndProc // "Enter the Encoding Window" Registration Function

3 2 0000FB50 IMEConfigure // Configure the current IME parameter function

4 3 0000Fec0 ImeconversionList // Convert characters or strings into target characters 5 4 0000ffa0 imedestroy // Exit the current IME

6 5 000030D0 IMEENUMREGISTERWORD

7 6 0000FFB0 IMEESCAPE // Application Software Access the interface function of the input method.

8 7 00003080 ImegetRegisterWordStyle

9 8 0000E9A0 IMEINQUIRE // Start and initialize the current IME input method

10 9 0000A800 IMEPROCESSKEY / / IME Enter the keyboard event management function

11 A 00002C20 IMEREGISTERWORD / / Registration string to the input Dictionary

12 b 000109A0 IMESELECT // Start the current IME input method

13 C 000109E0 IMESETACTIVECONTEXT / / Set the current input is active.

14 d 0000c850 IMESETCompSitionstring is encoded by the application settings

15 E 0000Aee0 ImetoasciIEx // convert the input keyboard event to Chinese character encoding events

16 f 00002f40 ImeunRegisterWord // Delete the registered string.

17 10 0000ca90 Notifyime // IME Event Management Function

18 11 00005160 StatusWndProc // Status window registration function

19 12 00002350 UiWndProc // User interface interface function

Summary

5000.Shareda

7000.data

2000 .idata

1000.rdata

3000 .reloc

5000.RSRC

2000.sgroup

18000 .Text

As can be seen from the above, there is a total of 19 outlet functions, each function has a specific format, which is responsible for the function of delivering information with the Windows system, which is for Windows system calls.

Third, the function of the input method

Below we will introduce the functions and interface formats of each of the above functions.

Bool ImeINQUIRE (// Initialization IME

LPIMEINFO LPIMEINFO, / / ​​/ / Used to initialize the structure address of the input method

LPTSTR LPSZWNDCLASS, // The name of the current input method

LPCTSTSTR or DWORD LPSZDATA / / system information, 9X series value is 0, and there is actual value under NT / 2000

)

If the function initializes success, return to Ture, otherwise false

Users should figure out the Imeinfo structure, specially related to whether the input method you design is successful. Please see the "Structure" chapter on this structure.

2.Dword IMEConVersionList (// convert a character or string into target string

HIMC HIMC, / / ​​Application handle related to the current input method

LPCTSTRLPSRC, // To convert the string (or possibly the result string, can be specified by uflag)

LPCandIDateList LPDST, /// Converted strings (or source string can be specified by uflag)

DWORD dwbufflen, // There are several characters after conversion

UINT UFLAG / / Specified Save Location

)

If successful, return the conversion string length

3.Bool IMEConfigure (// User Settings Input Method Interface

HKL HKL, // Current input method handle

HWND HWND, // Configure the parent window of the window

DWORD dwmode, // What is configured?

LPVOID LPDATA // User Settings Data

)

The function of this function is to provide a user that can change certain implicit settings.

If you have used the input method of others, "Configure Input Method ..." features are both also!

For a person who enters the input method, you can not be given.

4.Bool iMedestroy (// Turn off the current input method

UINT URESERVED / / Unused (0)

)

Successfully returns Ture, otherwise false

5.lResult Imescape (// User Software Access Input Method Interior Information

HIMC HIMC, // Current application handle

UINT uescape, // set function function

/ / = IME_ESC_QUERY _SUPPORT

/ / = IME_ESC_RESERVED_LAST IME_ESC_RESERVED_FIRST

/ / = IME_ESC_PRIVATE_FIRST IME_ESC_PRIVATE_LAST

/ / = IME_ESC_SEQUENCE_TO_ INTERNAL

/ / = IME_ESC_GET_EUDC_ DICTIONARY

/ / = IME_ESC_SET_EUDC_ DICTIONARY

/ / = IME_ESC_MAX_KEY

/ / = IME_ESC_IME_NAME

/ / = IME_ESC_SYNC_HOTKEY

/ / = IME_ESC_HANJA_MODE

/ / = IME_ESC_GETHELPFILENAME (only Windows 98 and Windows 2000)

/ / = IME_ESC_PRIVATE_HOTKEY (W95 is not available)

LPVOID LPDATA // Data required for current features

)

If it fails, return 0, otherwise there is a functional decision

Sometimes, people can use this function of the navigation name, help the file name, etc. Of course, we can not provide these features.

6, BOOL IMESETACTIVECONTEXT (// Activates or puts the current input method

HIMC HIMC, // Current User Program Handle

BOOL FFLAG / / Activation or Shelving: = True Activation = False Shelving

)

Successfully returns True, otherwise false

7, BOOL IMEPROCESSKEY (// Handling all key key events incorporated by the application, monitoring if it is required for the current input method

HIMC HIMC, // Application handle

Uint uvirkey, // Need to process the virtual key

DWORD LPARAM, // Key Message Parameters

Const lpbyte lpbkeystate // Current keyboard status (256 bytes)

)

Returns true if this button is required, then returns true, otherwise false

Only return True keystrokes, IME deals

8, BOOL NOTIFYIME (// input method selection window status management function:

HIMC HIMC, // Current application handle

DWORD dwaction, // status value

DWORD DWINDEX, / / ​​Sequence number related to status values

DWORD DWVALUE / / Value related to status values

)

Status value description:

= NI_OpenCandIdate Opens the Code Select Window

= Ni_closecandidate Close the current encoding selection window

= Ni_Selectcandidatestr Select the encoding

At this time: DWIndex is selected by the encoded list.

DWValue is selected in the number in the current coding list

= Ni_changecandidatelist change the current encoding list (pressing PageUp)

At this time: DWIndex is selected by the encoded list.

DWValue is not available

= Ni_setcandidate_pagestart Settings the encoding start page number

At this time: DWIndex is changed to the encoded list number

DWValue's start number of new pages.

= Ni_setcandidate_pageSize Change the size of the code list page

At this point: Dwindex currently encoded page number

DWValue new page size

= Ni_ContextUpdated Update the information of the input method of the application: move the location, set mode, set the encoding window, font. At this time: DWINDEX is only used for dwvalue = imc_setconversionMode, IMC_SetSentenceMode

DWValue can take the following values ​​sent by WM_IME_CONTROL:

IMC_SetcandidatePOS

IMC_SETCompositionFont

IMC_SETCompositionWindow

IMC_SETCONVERSIONMODE

IMC_SetSentenceMode

IMC_SETOPENSTATUS

= Ni_compositionstr Change the encoding in the encoding window

At this point: DwINDEX Remove the column value: CPS_COMPLETE completes the encoding conversion

CPS_CONVERT conversion coding

CPS_REVERT Cancels the current encoding

CPS_CANCEL Clear the encoding and turn off the encoding window

DWValue is not available

This function is successful, returns True, otherwise false

9, BOOL IMESELECT (// Initialization input method

HIMC HIMC, // Current application handle

BOOL FSELECT / / Do I initialize the current input method, True is initialized

)

Return: Successful returns true, otherwise false

. The iMe..

10, BOOL WINAPI IMESETCOMPSITIONSTRING (// In encoding the encoding in the encoded window,

// Comrade Sending the message completed by the encoding

/ / (Wm_ime_composition) to the system,

HIMC HIMC, // Current application handle

DWORD DWINDEX, // Set this function function

// = SCS_SETSTR

// = SCS_CHANGEATTR

// = SCS_CHANGECLASE

// = SCS_QUERYRECONVERTSTRING

// = SCS_RECONVERTSTSTRING

// = SCS_SETRECONVERTSTRING

LPCVOID LPComp, // Code Data Area

DWORD DWCOMPLEN, // Code Data Area Length

LPCVOID LPREAD, // Read Code Data

DWORD DWREADLEN // Read Code Data Length

)

11, uint iMetoasciiex (// conversion coding called Chinese characters (string)

UINT UVIRKEY, / / ​​虚键

UINT USCANCODE, / / ​​Scan code

Const lpbyte lpbkeystate, // user-defined keyboard status

LPDWORD LPDWTRANSBUF, // Translated Data Storage Area

Uint fustate, // activity menu flag

HIMC HIMC // Current application handle

)

Return: The return value indicates a few messages, and it is understood that the Chinese character string corresponding to this encoding has several Chinese characters (of course, this is not equal).

12, BOOL WINAPI IMEREGISTERWORD (

LPCTSTR LPSZREADING,

DWORD DWSTYLE,

LPCTSTR LPSZSTRING

)

13, BOOL WINAPI IMEUNREGISTERWORD (LPCTSTR LPSZREADING,

DWORD DWSTYLE,

LPCTSTR LPSZSTRING

)

14, uint WinApi

ImegetRegisterWordStyle

Uint Nitem,

LPStyleBuf LPStylebuf

)

15, uint WinApi IMEENUMREGISTERWORD (

HKL,

RegisterWordenumProc LPFNENUMPROC,

LPCTSTR LPSZREADING,

DWORD DWSTYLE,

LPCTSTR LPSZSTRING,

LPVOID LPDATA

)

16, DWORD WINAPI IMEGETIMEMEMENUITEMS

HIMC HIMC,

DWORD DWFLAGS,

DWORD DWTYPE,

LpimeMenuItemInfo LpimeParentMenu,

LpimeMenuItemInfo LpimeMenu,

DWORD DWSIZE

)

Four. IME version information (the difference from ordinary DLL)

VS_VERSION_INFO VERSIONINFO represents characters meaning

Fileversion 4, 0, 0, 950 //4.00.950 95

ProductVersion 4, 0, 0, 950 //4.00.950 95

Fileflagsmask 0x3fl

FILEFLAGS 0XAL

FILEOS 0x10004L / / VOS_DOS_WINDOWS32 WIN32 software can be run under DOS

FILETYPE 0x3L // VFT_DRV driver

FILESUBTYPE 0XBL / / VFT2_DRV_INPUTMETHOD input method driver

Begin

Block "stringfileinfo"

Begin

Block "080403A8"

Begin

Value "comments", "/ 0"

Value "CompanyName", "Tang code software development studio / 0"

Value "FileDes Cription", "Tang code input method version 1.0 / 0"

Value "Fileversion", "4.00.950 / 0"

Value "InternalName", "Tang code input method version 1.0 / 0"

Value "legalcopyright", "Copyright (c) Tang code software development studio 1999-1999 / 0"

Value "legaltrademarks", "/ 0"

Value "OriginalFileName", "TM.IME / 0"

Value "PrivateBuild", "/ 0"

Value "ProductName", "Tang code input method version 1.0 / 0"

Value "ProductVersion", "4.00.950 / 0"

Value "Specialbuild", "/ 0"

End

Chapter II IME Management Function provided by Windows9x System

The previous chapter, we introduced the functions that must be designed in the IME file, these functions have to be designed by us. To complete the design of these functions, you need to use the management function provided by the Windows system (IMM).

The IMM function can be used by the IME function, or it can also be used directly to manage IME directly.

Related terms:

(1) INPUT METHOD CONTEXT is referred to as an IMC-input method related section, which is explained here: Related Application (Process) (2) Component Of The Input Context is referred to as IMCC - IMC components, is a member of the INPUTCONTEXT structure.

First, the IMM function list used in IME

ImmgetCompositionWindow // Take an encoded window information

ImmsetCompositionWindow // Set the encoding window information

ImmgetcandidateWindow // Select window information

ImmsetCandIdateWindow // Settings Select Window Information

ImmgetCompationstring // Take some information of the encoded window

ImmsetCompositionString // Sets an information on the encoding window

ImmgetCompositionFont // Addition font

IMMSETCompositionFont // Setting the encoded font

ImmgetnumcandidateList // Take the number of codes in the selection area

ImmgetcandidateList // Take the selection area encoding

ImmgetGuideline

ImmgetConversionsStatus // Take the status of the current input method (ACSII, Shape, Full, etc.)

ImmgetConversionList // Re-gain Select Zone Conversion Table

ImmgetopenStatus // Take the input method to open the properties

ImmsetConversionsStatus // Setting the input method status

IMMSETOPENSTATUS / / Settings Input Method Open Status

Immnotifyime / / Inform IME, input method is changed

ImmgenerateMessage // Sends our Chinese character string to the application associated with the current input method

ImmmRequestMessage / / Send WM_IME_REQUEST to the application

Immlockimc // Get the current IMC's InputContext structure information, increase the IMC counter

ImmunlockIMC / / Release IMC Counter

ImmgetimClockCount // Take the counter value

ImmcreateImcc // Creating a member of the InputContext structure

ImmdestroyImcc // Remove IMC Member Buffer

Immlockimcc // Take an IMCC buffer address while adding the IMCC counter value

ImmunlockIMCC // Decrease IMCC Counter

ImmresizeImcc // Reset the buffer size of the member of the IMC

Immgetimccsize // Take the buffer size of the IMC member

ImmgetImcClockCount // Return to IMC Counter Value

ImmgetHotKey // Take the input method status button, the function is used to control the panel

IMMSETHOTKEY / / setting hot key

ImmcreateSoftKeyboard // Generate a soft keyboard

ImmdestroySoftKeyboard // Destroy soft keyboard

Immshowsoftkeyboard // Show or hide soft keyboard

Second, IMM functions use format description

1, BOOL WINAPI IMMGENERATEMESSAGE (// Sends our Chinese character string to the application associated with the current input method

HIMC HIMC / / The handle of the application software associated with the current input method,

/ / The HMSGBUF item of this structure is a Chinese character string message

)

Success is True, otherwise false

2, LRESULT WINAPI IMMREQUESTMESSAGE (// Send WM_IME_REQUEST to the application

// only for W98 and W2000

HiMC HIMC, / / ​​The handle of the application associated with the current input method

WPARAM WPARAM, / / ​​WP associated with WM_IME_REQUEST

LPARAM LPARAM / / LP related to WM_IME_REQUEST

// = IMR_CompositionWinow // = IMR_CAndidateWindow

// = IMR_CompositionFont

// = IMR_ReconvertString

// = IMR_ConfirmReconvertString

// = IMR_QueryCharPosition

// = IMR_Documentfeed

)

3, LPINPUTCONTEXT WINAPI IMMLOCKIMC (// Gets the current IMC INPUTCONTEXT structure information, increase the IMC counter

HIMC HIMC // Current Application Handle

)

Successfully returns the InputContext structure pointer, otherwise null

4, BOOL WINAPI IMMunlockIMC (// Release IMC Counter

HIMC HIMC // Current Application Handle

)

Returns: If the IMC counter is reduced to 0, return false, otherwise true.

Note: IMMLOCKIMC and IMMunlockIMC must be paired, must be the same HIMC

5, hiMCC WinApi ImmgetimClockCount (// Take the counter value

HIMC HIMC // Current Application Handle

)

If it successfully returns the HIMC counter value, it is null.

6. Himcc WinAPI ImmcreateImcc (// Creating a member of the InputContext structure

DWORD DWSIZE // Member Buffer Length

)

If successfully returns the member handle of the IMC, otherwise null

7, himcc winapi immdestroyimcc (// Remove IMC member buffer

Himcc himcc // deleted IMC member

)

If the NULL is successfully returned, it is equal to this HIMCC.

8, LPVOID WINAPI IMMLOCKIMCC (// Take an IMCC buffer address, and increase the value of the IMCC counter value

HIMCC HIMCC / / IMC Member Handle

)

IF the Return Value is The Pointer for The Imc Component. OtherWise, The Return Value is Null.

9, BOOL WINAPI IMMunlockIMCC (// Decreasing IMCC Counter

HIMCC HIMCC / / IMC Member Handle

)

If the IMCC's counter value is zero, return false, otherwise true.

10. HIMCC WINAPI ImmresizeIMCC (// Reset the buffer size of the member of the IMC

HIMCC HIMCC, // IMC member handle

DWORD DWSIZE / / New Buffer Size

)

If successful, return to the new HIMCC, otherwise null.

11, DWORD WINAPI ImmgetImcccsize (// Take the size of the IMC member

HIMCC HIMCC / / IMC Member Handle

)

Returns the size of the buffer of IMC members

12, DWORD WINAPI IMMGETIMCCLOCKCOUNT (// Returns IMC Counter value

Himcc HIMCC / / IMC member handle

)

Successfully returns the counter value of the IMCC, otherwise 0

13, BOOL WINAPI ImmgetHotKey (// Take the input method status, the function is used to control the panel

DWORD DWHOTKEYID,

LPUINT LPUMODIFIERS,

Lpuint Lpuvkey,

LPHKL LPHKL

)

14, BOOL WINAPI IMMSETHOTKEY (// Setting the hotkey for input method

DWORD DWHOTKEYID,

Uint umodifiers,

UINT UVKEY,

HKL HKL

)

15. HWND WinApi ImmcreatesoftKeyboard (// produces a soft keyboard uint utype, // software on the key code meaning

// = SoftKeyboard_type_t1

// = SoftKeyboard_type_c1

UINT HOWNER, / / ​​UI window for this input method

INT x, / / ​​positioning coordinates

INT Y / / Positioning coordinates

)

Successfully returned to the window handle of the soft keyboard

16, BOOL WINAPI IMMDESTROYSOFTKEYBOARD (// Destroy soft keyboard

HWND HSOFTKBDWND / / Soft Annopsis Handle

)

Success is true, the law is False.

17, BOOL WINAPI IMMSHOWTKEYBOARD (// Displayed or hidden soft keyboard

HWND HSOFTKBDWND, / / ​​Soft Annopsis Handle

INT ncmdshow // window status = sw_hide means hidden, = sw_shownoactivate representation

)

Returns true if it is constant. Otherwise, false.

Chapter III Must Used in Ime File

The first two chapters we talked about the IME and IMM functions, and both of them rely on the following structural communication.

1, Imeinfo

The interface information of the struct tagimeinfo {// input method is used in the IMEINQUIRE function.

DWORD dwprivateDataSize; // User's byte number of data structures

DWORD fdwproperty; // input method to the corresponding feature of the keyboard event

// The high character can be a combination of the following byhenonics:

/ / = IME_PROP_AT_CARET Conversion window is placed in the location where you need to insert characters

/ / = IME_PROP_SPECIAL_UI This input method has a special user interface

/ / = IME_PROP_CANDLIST_START_FROM_1 Input method selection window The starting number of the Chinese character string is 1

/ / = IME_PROP_UNICODE Support Unicode Character

// The low word can be a combination of the following byhenonics:

/ / = IME_PROP_END_UNLOAD

/ / = IME_PROP_KBD_CHAR_FIRST first by the keyboard conversion character

// = IME_PORP_NEED_ALTKEY Transfer the ALT keyboard event to the IME input method

/ / = IME_PROP_IGNORE_UPKEYS Prohibits the upper key event into the input method

/ / = IME_PROP_COMPLETE_ON_UNSELECT When turning off the input method, complete the encoded conversion

// Used in W98 and 2000

DWORD fdwconversioncaps; // The current input method has functional characteristics, such as soft keys, punctuation, Chinese and Western switching

/ / = IME_CMODE_NATIVE Setting Activity Mode

/ / = IME_CMODE_FULLSHAPE Set the full corner mode

/ / = IME_CMODE_CHARCODE Set as Character Mode

/ / = IME_CMODE_SOFTKBD // Set soft keyboard mode

/ / = IME_CMODE_NOCONVERSION / / Do not support mode transformation

/ / = IME_CMODE_EUDC //

/ / = IME_CMODE_SYMBOL / / Set Branch Character Mode

DWORD fdwsencecaps; //

/ / = IME_SMODE_PLAuralClause

/ / = IME_SMODE_SINGLECONVERT

/ / = IME_SMODE_AUTOMETIC

/ / = IME_SMODE_CONVERSATION

DWORD FDWUICAPS; // User interface capability: Support soft keyboard, etc.

// = ui_cap_2700

/ / = Ui_cap_rot90

// = ui_cap_rotany

/ / = Ui_cap_sofkbd

DWORD fdwscscaps; // User Set the capabilities of the encoded string / / = SCS_CAP_COMPSTR

// = SCS_CAP_MAKEREAD

DWORD fdwselectcaps; // Whether to use the previous input method when switching

// = SELECT_CAP_CONVMODE

// = SELECT_CAP_SENTENCE

IimeInfo;

2, CompositionSTR is used to code management

Typedef struct tagcompositionstr {// Information for storing coding information: All actual information is placed behind this structure

DWORD dwsize; // Currently Code Information Required Storage Space = Reading Coded Properties Scer Properties Code Properties Results Properties

DWORD dwcompreadattrlen; // Read the encoding attribute length

DWORD dwcompreadattroffset; // stored in memory

DWORD DWCompReadclslen; // Read the subsidence length

DWORD dwcompreadclsoffset; // Store in memory

DWORD dwcompreadstrlen; // Read the encoding length

DWORD DWCompReadStroffset; // Store in memory

DWORD dwcompattrlen; // Code properties length

DWORD dwcompattroffset; // stored in memory

DWORD dwcompclslen; // encoding substring length

DWORD dwcompclsoffset; // stored in memory

DWORD DWCompstrlen; // Code String Length

DWORD dwcompstroffset; // stored in memory

DWORD dwcursorpos; // Current cursor location

DWORD dwdeltastart; // Changed the location of the encoded

DWORD dwresultreadclslen; // Read the result substring length

DWORD dwresultreadclsoffset; // stored in memory

DWORD DWRESULTREADSTRLEN; // Reading Code Length

DWORD DWRESULTREADSTROFFSET; // Store in memory

DWORD dwresultclslen; // Results Subsidence length

DWORD dWResultclsoffset; // stored in memory

DWORD dwresultstrlen; / / Results String length

DWORD DWRESULTSTROFFSET; // Store in memory

DWORD dwpriVatesize; // User Custom Data Length

DWORD dwprivateoffset; // Store in memory

Compositionstr;

3. CandidateInfo is used for coding selection management

TypeDef struct tagcandidateIndIDEFO {// encodes the information of the selection information, after the actual coding list data

DWORD DWSIZE; / / Data occupying the memory size

DWORD dwcount; // Table horse list

DWORD DWOFFSET [32]; // Memory location of each encoded list

DWORD dwpriVatesize; // Custom data size

DWORD dwprivateOffset; // buffer location

CandidateInfo;

4, Guideline

Typedef struct tagguideline {

DWORD DWSIZE;

DWORD dwlevel; // the error level.

// GL_LEVEL_NOGUIDELINE,

// GL_LEVEL_FATAL,

// GL_LEVEL_ERROR,

// GL_LEVEL_WARNNING,

// GL_LEVEL_INFORMATION

DWORD DWINDEX; // GL_ID_NODictionary and so on.dword dwstrlen; // error strings, if this is 0, there

// is no error string.

DWORD DWSTROFFSET;

DWORD DWPRIVATESize;

DWORD dwprivateoffset;

Guideline;

5, Candidatelist

The Candidatelist Structure Contains Information About a Candidate List.

Typedef struct tagcandidatelist {// encoding selection list information => Manage the list information in the coding window

DWORD dwsize; // Memory size represented by byte: = SIZEOF (CandidateList) Select Character Data

DWORD DWSTYLE; / / list of reference strings

// = IME_CAND_UNKNOWN list data is not defined

/ / = IME_CAND_READ What data is read, why is it data, usually we use this attribute?

// = IME_CAND_CODE If dwcount = 1, dwoffset is not an address, but actual data,

//> 1 dwoffset represents the address

/ / = IME_CAND_MEANING

/ / = IME_CAND_RADICAL

/ / = IME_CAND_STROKES

DWORD DWCOUNT; / / Current list number

DWORD DWSELECTION; // Currently selected list sequence number

DWORD dWpageStart; // In the list of the list of lists (used up and down page)

DWORD dwpagesize; // A list of lists displayed

DWORD dwoffset []; // list data storage area address: [A]; [large]. . . .

} CandidateList;

6, CompositionForm

Typedef tagcompositionform {// window location, size information:

// Use IMC_SETCompositionWindow and IMC_SETCANDIDATEPOS message

DWORD DWSTYLE; / / Management window mode

// = CFS_DEFAULT Displays the encoded window to the hidden location

/ / = Cfs_force_position // is not affected by IME by a given coordinate display window

// = cfs_point // is controlled by IME by a given coordinate display window

// = cfs_rect // Display window at a given size

Point ptcurrentpos; // given coordinates

Rect rcarea; // Little given

Compositionform;

7, CandidateForm

The Candidateform Structure IS Used for IMC_GetcandidatePos and Imc_SetcandidatePos Messages.

TypeDef tagcandidateform {// list window information

// Processing by IMC_GetcandidatePos and IMC_SETCANDIDATEPOS

DWORD DWINDEX; / / list window serial number

DWORD DWSTYLE; / / Property:

/ / = Cfs_candidatePos Specify the display location

/ / = CFS_EXCLUDE is not displayed

// = CFS_DEFAULT Display as needed

Point ptcurrentpos; // coordinate position

Rec rcarea; // cannot be displayed

CandidateForm;

8, STYLEBUF

Typedef struct tagstylebuf {// registered word structure DWORD DWSTYLE

TCHAR SZDES CRIPTION [32]

STYLEBUF;

9, Softkbddata

Typedef struct tagsoftkbddata {// 软 软

UINT UCOUNT; // Key code number (can be 1, 2, when distinguishing the SHIFT button, ie: a set of Shift, a group does not bring Shift)

Word wcode [] [256] // Corresponding key code data

} Softkbddata;

10, ReconvertString

Typedef struct _tagreconvertstring {// for W98 and 2000

DWOPD DWSIZE;

DWORD DWVERSION;

DWORD DWSTRLEN;

DWORD DWSTROFFSET;

DWORD DWCompstrlen;

DWORD DWCompStroffset;

DWORD DWTARGETSTRLEN

DWORD DWTARGETSTROFFSET;

} ReconvertString;

11, IMEMENUITEMINFO

Typedef _tagimeMenuItemInfo {// Input Menu Structure, W98 / 2000

Uint CBSIZE;

Uint ftype;

Uint fstate;

Uint WID;

Hbitmap hbmpchecked;

Hbitmap hbmpunchecked;

DWORD DWITEMDATA;

Tchar szstring [48];

Hbitmap hbmpitem;

}

12, INPUTCONTEXT

The INPUTCONTEXT STRUCTURE IS ANAL DATA STRUCTURE THAT INPUT CONTEXT DATA.

Typedef struct taginputcontext {// IMC data storage area

HWND HWND; // Use this IMC window

Bool Fopen; // IME Opening and Close State

Point PtStatusWndPos; // Location of the Status window

Point PTSoftkbdpos; / / soft keyboard location

DWORD fdwconversion; // IME status (activity, inactivity, full corner, etc.)

DWORD fdwsence; // encoding method

Union {

Logfonta a;

Logfontw W;

} lffont; // font

Compositionform cfcompform; // encoding format structure

CandidateForm Cfcandform [4]; // List Select Structure

HIMCC HCompStr; //

Himcc hcandinfo;

Himcc HGUIDeline

Himcc HpriVate;

DWORD DWNUMMSGBUF; // Number of messages stored in HMSGBUF

Himcc hmsgbuf; // store message, format: [message 1] [wparam1] [lparam1] {[message] [wparam2] [lparam2] ...

// Note: The Chinese characters we entered are placed here.

DWORD fdwinit // The system is based on this value to initially the corresponding information.

// = init_statuswndpos initialization PTSTATUSWNDPOS

// = init_conversion initialization FDWConversion

// = init_sentence initialization fdwsence

// = init_logfont initialization LFFont

// = init_compform initializes CFCompform

// = init_softkbdpos initialization PTSoftkbdposdword dwreserve [3]; // Future version extension information

InputContext;

The following Windows messages are required under the UI window.

1, WM_IME_SETCONTEXT

Activate or sleep input method

LResult Callback UiWndProc (HWnd HuiWnd, Uint UMSG, WPARAM WPARAM, LPARAM LPARAM)

{

:

Case WM_IME_SETCONTEXT:

Fset = (bool) wparam;

Liscbits = lparam;

}

If FSET is true, the system will activate a window (status window, list window, etc.) of the current input method (state window, list window, etc.) to sleep for FALSE.

Which window operation is pointed out in LiscBits.

Numerical meaning

ISC_SHOWUICompositionWindow Displays the encoding window

ISC_ShowuiGuidWindow Display Information Window

ISC_ShowuicandidateWindow Displays the No. 0 list window

(ISC_SHOWUICANDIDATEWINDOW << 1) Displays the No. 1 list window.

(ISC_SHOWUICANDIDATEWINDOW << 2) Displays the No. 2 list window.

(ISC_SHOWUICANDIDATEWINDOW << 3) Displays the No. 3 list window.

2, WM_IME_CONTROL

Management current input method

WSUBMESSAGE = WPARAM; message controlled by WM_IME_CONTROL

LPDATA = (LPVOID) LPARAM; corresponding data

Among them, there are the following messages:

1) IMC_GetcandidatePos

Get the location of the list window. At this time, LPARAM is transmitted is the CandidateForm structure address.

If this message successfully returns 0, no zero.

Usually if you design this part, return 0. Otherwise returns 1.

2) IMC_GetCompositonfont

Get the coding window font structure, lparam is logfont structure address

If this message successfully returns 0, no zero.

Usually if you design this part, return 0. Otherwise returns 1.

3) IMC_GetCompositonWindow

Get the encoding window position, lparam is the CompositionForm structure address.

If this message successfully returns 0, no zero.

Usually if you design this part, return 0. Otherwise returns 1.

4) IMC_GETSOFTKBDFONT

Get the soft keyboard font. LPARAM Font Structure LogFont Address.

5) IMC_GETSOFTKBDPOS

Get soft keyboard position, lpaam = 0;

Returns the coordinate structure Points in the soft keyboard in the screen window.

6) IMC_GETSOFTKBDSUBTYPE

WSUBMESSAGE = IMC_GETSOFTKBDSUBTYPE;

LPARAM = 0;

7) IMC_GETSTATUSWINDOWPOS

Get the status window location

WSUBMESSAGE = IMC_GETSTATUSWINDOWPOS;

LPARAM = 0;

Returns the status window coordinate the coordinate structure in the screen window Points.

8) IMC_SETCANDIDATEPOS

WSUBMESSAGE = IMC_SETCANDIDATEPOS;

LPCandidateform = (lpcandidateform) LPARAM;

Set the location of the list window. At this time, LPARAM is transmitted is the CandidateForm structure address.

If this message successfully returns 0, no zero.

Note: The UI window does not accept this message, and its management function is Notifyime. 9) IMC_SETCompositonfont

Set the font of the encoded window. At this time, LPARAM is transmitted by the logfont structure address.

WSUBMESSAGE = IMC_SETCompSitionFont;

LPLOGFONT = (LPLOGFONT) LPARAM;

Note: The UI window does not accept this message, and its management function is Notifyime.

10) IMC_SETCompositonWindow

Set the encoded window properties, and LParam is transmitted in the CompositionForm structure address.

WSUBMESSAGE = IMC_SETCompositionWindow;

LPCompositionForm = (lpCompositionform) LPARAM;

If this message successfully returns 0, no zero.

Note: The UI window does not accept this message, and its management function is Notifyime.

11) IMC_SETSOFTKBDDATA

Set the soft keyboard data, at which point LParam is transmitted is the SoftkbDData structure address, and the user sets its own soft keyboard characters.

WSUBMESSAGE = IMC_SETSOFTKBDDATA;

LPSOFTKBDDATA = (lpsoftkbdddata) lparam;

If this message successfully returns 0, no zero.

Note: The UI window does not accept this message, and its management function is Notifyime.

12) IMC_SETSOFTKBDSUBTYPE

Set soft keyboard type

WSUBMESSAGE = IMC_SETSOFTKBDSUBTYPE;

Lsubtype = lparam;

Successfully returned subtype, otherwise returns -1.

Note: The UI window does not accept this message, and its management function is Notifyime.

13) IMC_SETSOFTKBDFONT

Set the soft keyboard font, and the LPARAM is transmitted is the logfont structure address.

WSUBMESSAGE = IMC_SETSOFTKBDFONT;

LPLOGFONT = (LPLOGFONT) LPARAM;

If this message successfully returns 0, no zero.

Note: The UI window does not accept this message, and its management function is Notifyime.

14) IMC_SETSOFTKBDPOS

Set the software location, at this time, LParam is transmitted by the Points structure.

WSUBMESSAGE = IMC_SETSOFTKBDPOS;

PTSPT = (Points) LPARAM;

If this message successfully returns 0, no zero.

15) IMC_SETSTATUSWINDOWPOS

Set the status window location, at this time, LPARAM is transmitted by the POINTS structure.

WSUBMESSAGE = IMC_SETSTATUSWINDOWPOS;

PTSPT = (Points) LPARAM;

If this message successfully returns 0, no zero.

3, WM_IME_COMPSITION

When the user changed the encoded state, send this message WM_IME_COMPSITION

Applications can get new encoded status by calling ImmgetCompationstring.

Wchar = wparam; finally entering 2 bytes of DBCS characters to the encoded window

Lattribute = lparam; currently coded meaning.

Lattribute can take the following list:

Value meaning

GCR_ERRORSTR correction error

GCR_INFORMATIONSTR correction information string

GCS_COMPATTR Fixed the encoded string properties.

GCS_COMPCLAUSE Fixed Code Information. GCS_CompReadattr correction of the properties of the read string

GCS_COMPREADCLASE Fixed the properties of the read string.

GCS_CompReadStr correction read string.

GCS_CompStr Corrects Current Coding

GCS_CURSORPOS corrects the currently encoded cursor position.

GCS_DELTASTART corrects the current encoded start position

GCS_RESULTCLASE corrects information of the result string.

GCS_ResultReadClause fixes the information of the read string.

GCS_RESULTREADSTR correction is written.

GCS_RESULTSTR corrects the coding result string.

CS_INSERTCHAR inserts a character in the current location

CS_NOMOVECARET replacement result string

4, WM_IME_COMPSITIONFULL

When the user interface window does not increase the size of the encoded window, the IME user interface window will send a WM_IME_COMPSISITIONFULL message and may not process.

WPARAM = 0

LPARAM = 0

5, WM_IME_ENDCOMPSITION

When the encoding ends, IME sends this message WM_IME_ENDComposition

WPARAM = 0

LPARAM = 0

User programs can accept this message so that you can display the user's encoding.

6, WM_IME_SELECT

The system issues WM_IME_SELECT to select a new IME.

FSelect = (BOOL) WPARAM; true Represents the new IME has been selected, FALSE means that the input method is not selected or turned off.

HKL = LPARAM;

The system uses this message to generate or close the old input method user window.

7, WM_IME_STARTCOMPSITION

When the user starts entering the encoding, the system immediately sends the message to the IME, IME opens the encoding window.

WPARAM = 0

LPARAM = 0

8, WM_IME_NOTIFY

IME message group:

WSUBMESSAGE = WPARAM;

LPARAM = LPARAM;

Each news description:

1) IMN_CLOSESTATUSWINDOW

When the status window is turned off, the system sends an IMN_CloseStatusWindow message.

WSUBMESSAGE = IMN_CloseStatusWindow;

LPARAM = 0;

When the user interface window receives this message, the status window is turned off.

2) IMN_OPENSTATUSWINDOW

Generate or open the status window

WSUBMESSAGE = IMN_OPENSTATUSWINDOW;

LPARAM = 0;

When IME receives this message, a status window will be generated.

Information about the status serial port can be obtained with ImmgetConversionStatus, and the information of the setting status window can be used in IMMSETCONVERSIONSTATUS.

3) IMN_OpenCandidate

Open or generate a list selection window

WSUBMESSAGE = IMN_OpenCandIdate;

Lcandidatelist = lparam;

4) IMN_CHANGECANDIDATE

Update the current list selection window

WM_IME_NOTIFY

WSUBMESSAGE = IMN_CHANGECANDIDATE;

Lcandidatelist = lparam;

5) IMN_Closecandidate

Close selection window

WSUBMESSAGE = IMN_ClosecandIdate;

Lcandidatelist = lparam;

After receiving this message, the UI window receives the window selection window.

IMN_SETCONVERSIONMODE

Changing input method status mode management

WSUBMESSAGE = IMN_SETCONVERSIONMODE; LPARAM = 0;

IMN_SETOPENSTATUS

Set the input method status

WSUBMESSAGE = IMN_SETOPENSTATUS;

LPARAM = 0;

IMN_SETCANDIDATEPOS

Set list window location

WSUBMESSAGE = IMN_SETCANDIDATEPOS;

Lcandidatelist = lparam;

Parameters

IMN_SETCOMPSITIONFONT

Set the encoding window font

WSUBMESSAGE = IMN_SETCompSitionFont;

LPARAM = 0;

IMN_SETCOMPSITIONWINDOW

Set the encoding window

WSUBMESSAGE = IMN_SETCompositionWindow;

LPARAM = 0;

IMN_GUIDELINE

Error message processing

WSUBMESSAGE = IMN_GUIDELINE;

LPARAM = 0;

IMN_SOFTKBDDESTROYED

Turn off soft keyboard

WSUBMESSAGE = IMN_SOFTKBDDESTROYED;

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

New Post(0)