Implementation of Windows Chinese Input Method

zhaozj2021-02-16  49

Implementation of Windows Chinese Input Method

I designed a "3 input method", running the operating system Windows95 / 98 / NT / 2000, "3 input method" is a pure code, no need to identify the code, easy to learn, easy to use, fast entry speed, including "Simplified, Traditional, Professional", small quantity, the number of phrases is greater than 26,000, all of which are only 73, you can search "3 in http://www.9cbs.net/cnshare/ Input Method Download Software, or at: http://www.anycities.com/user1/3j/ Download. Welcome all the trials and make valuable comments. If you have any questions, email: w3jj@yahoo.com.cn gives me. Limited to space, the basic principle of Chinese character input method under the Windows system, you can refer to the relevant documentation in MSDN. I only describe the implementation method of programming as follows: 1. Increase the input method name in the Windows taskbar, which is the key to the setup program. In fact, the ImminstallIMe function can be utilized. The original shape of this function is: HKL Imminstallime (LPCTSTSTR LPSZLAYOTTETEXT); the previous parameter lpszimeFileName is the path of ".IME" file, WinNX is "/ system", Winnt / 2000 is "/ system32". The latter parameter lpszLayoutText is the illustration of the input method. Such as HKL Myime = Imminstallime ("Windows // System // 3Jaja.ime", "3 Input Method"); if Myime does not return null, call success. Of course, you must first design the DLL program ".IME" file and code table original file ".mb" file.

Second, ". IME" file The output function in the program (must) ie the function in the file ".def", the following is the name and prototype of the function, some functions give the original function, I hope to help you can help you .

// initialization input function BOOL WINAPI ImeInquire (LPIMEINFO lpImeInfo, LPTSTR lpszWndCls, DWORD lpszOptions) {if return (FALSE); lpImeInfo-> dwPrivateDataSize = sizeof (PRIVCONTEXT); (lpImeInfo!) LpImeInfo-> fdwProperty = IME_PROP_KBD_CHAR_FIRST | IME_PROP_CANDLIST_START_FROM_1 | IME_PROP_IGNORE_UPKEYS ; lpImeInfo-> fdwConversionCaps = IME_CMODE_NATIVE | IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE | IME_CMODE_CHARCODE | IME_CMODE_SOFTKBD | IME_CMODE_NOCONVERSION; lpImeInfo-> fdwSentenceCaps = 0; lpImeInfo-> fdwUICaps = UI_CAP_ROT90 | UI_CAP_SOFTKBD; lpImeInfo-> fdwSCSCaps = SCS_CAP_COMPSTR | SCS_CAP_MAKEREAD; lpImeInfo-> fdwSelectCaps = (DWORD 0; LSTRCPY (LPSZWNDCLS, (LPTSTSTSTSTSTSTSTSTS SZUICLASSNAME); Return (TRUE);} // Custom Chinese character encoding format, not processed. DWORD WINAPI ImeConversionList (HIMC hIMC, LPCTSTR lpszSrc, DWORD uBufLen, UINT uFlag) {return (0);} // set the input state function, such as a cursor and the like followed BOOL WINAPI ImeConfigure (HKL hKL, HWND hAppWnd, DWORD dwMode, LPVOID lpData ) {switch (dwMode) {case IME_CONFIG_GENERAL: DialogBox (hInst, MAKEINTRESOURCE (SETIME), (HWND) hAppWnd, (DLGPROC) ImeSetDlgProc); break; default: return (FALSE); break;} return (TRUE);} // exit BOOL WINAPI ImeDestroy (UINT uReserved) {if (uReserved) return (FALSE); return (TRUE);} // application interface function LRESULT WINAPI ImeEscape (HIMC hIMC, UINT uSubFunc, LPVOID lpData) {LRESULT lRet; switch (uSubFunc) {Case IME_ESC_QUERY_SUPPORT: IF (LPDATA == NULL) Return False;

switch (* (LPUINT) lpData) {case IME_ESC_QUERY_SUPPORT: case IME_ESC_MAX_KEY: case IME_ESC_IME_NAME: case IME_ESC_GETHELPFILENAME: return (TRUE); case IME_ESC_SEQUENCE_TO_INTERNAL: case IME_ESC_GET_EUDC_DICTIONARY: case IME_ESC_SET_EUDC_DICTIONARY: case IME_INPUTKEYTOSEQUENCE: return (FALSE); default: return (FALSE); } break; case IME_ESC_SEQUENCE_TO_INTERNAL: case IME_ESC_GET_EUDC_DICTIONARY: case IME_ESC_SET_EUDC_DICTIONARY: case IME_INPUTKEYTOSEQUENCE: return (FALSE); case IME_ESC_MAX_KEY: return ((WORD) 4); case IME_ESC_GETHELPFILENAME: {TCHAR szIMEGUDHlpName [MAXSTRLEN]; if (lpData == NULL) return FALSE ; szIMEGUDHlpName [0] = 0; GetWindowsDirectory ((LPTSTR) szIMEGUDHlpName, MAXSTRLEN); lstrcat ((LPTSTR) szIMEGUDHlpName, TEXT ( "// HELP // 3JaJa.hlp")); lstrcpy ((char *) lpData, (char *) szimegudhlpname); return true;

Default: return (false);

Return (LRET);} // Startup method setting function BOOL WINAPI IMESELECT (HIMC HIMC, BOOL FSELECT) {LPINPUTCONTEXT LPIMC; BOOL FRET;

IF (! hiMC) Return (false);

LPIMC = (LPINPUTCONTEXT) IMMLockIMC (HIMC); if (! lpim) return (false);

Fret = SELECT (HIMC, LPIMC, FSELECT); ImmunlockIMC (HIMC); Return (FRET);}

// Setting Input Activity Status Bool WinAPI ImesetActiveContext (HIMC HIMC, BOOL FON) {IF (FON && HIMC) {LPINPUTCONTEXT LPIMC;

LPIMC = (LPINPUTCONTEXT) IMMLockIMC (HIMC); if (! lpim) return (false);

INITCONText (LPIMC); ImmunlockIMC (HIMC);} Return (TRUE);

// User button processing function, such as a Chinese and English state, returning false as an English state, but the button is not processed. Bool WinApi ImeprocessKey (HIMC HIMC, UINT UVIRTKEY, LPARAM LPARAM, Const LPBYTE LPBKEYSTATE); // Input method encoded character processing. BOOL WINAPI ImeSetCompositionString (HIMC hIMC, DWORD dwIndex, LPVOID lpComp, DWORD dwCompLen, LPVOID lpRead, DWORD dwReadLen); // convert user key character encoding UINT WINAPI ImeToAsciiEx (UINT uVirtKey, UINT uScanCode, CONST LPBYTE lpbKeyState, LPTRANSMSGLIST lpTransBuf, UINT Fustate, HIMC HIMC) // Process IME Message Function BOOL WINAPI NOTIFYIME (HIMC HIMC, DWORD DWAction, DWORD DWINDEX, DWORD DWVALUE); // Custom Chinese Character Coding Format, Not Processing. Bool WinAPI ImeregisterWord (LPCTSTR LPSZREADING, DWORD DWSTYLE, LPCTSTR LPSZSTRING) {return (false);} // Custom Chinese character encoding format, unprocessed processing. Bool WinAPI ImeunRegisterWord (LPCTSTSTYLE, LPCTSTSTR LPSZSTRING) {Return (false);

// Customize the Chinese character encoding format, not processed. Uint WinApi ImegetRegisterWordStyle (uint nitem, lpstylebuf lpstylebuf) {return (false);}

// Customize the Chinese character encoding format, not processed. UINT WINAPI IMEENUMREGISTERWORD (RegisterWordenumProc, lpctstr lpszreading, dword dwstyle, lpctstr lpszstring, lpvoid lpdata) {return (false);}

// UI window procedure LRESULT CALLBACK UIWndProc (HWND hUIWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {switch (uMsg) {case WM_CREATE: CreateUIWindow (hUIWnd); break; case WM_DESTROY: DestroyUIWindow (hUIWnd); break; case WM_IME_STARTCOMPOSITION: } // process status window ...... LRESULT CALLBACK StatusWndProc (HWND hStatusWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); // process the code window LRESULT CALLBACK CompWndProc (HWND hCompWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); // Hou Choose the Chinese character window Process LRESULT CALLBACK CANDWNDPROC (HWND HcAndWnd, Uint UMSG, WPARAM WPARAM, LPARAM LPARAM);

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

New Post(0)