A Chinese input class does not want the IME to display the default window, just want to use its conversion and selection function, see some of the brothers on the Tiemato Forum, fix some BUG I think, joined a group Control function, make the program to display some Button, players can switch input, full corners, medium / English punctuation without having to use hot keys.
// I don't know if this can solve the problem of indentation #pragma comment (lib, "imm32.lib") #include
bool OnWM_INPUTLANGCHANGE (HWND hWnd); bool OnWM_IME_SETCONTEXT () {return true;} bool OnWM_IME_STARTCOMPOSITION () {return true;} bool OnWM_IME_ENDCOMPOSITION () {return true;} bool OnWM_IME_NOTIFY (HWND hWnd, WPARAM wParam); bool OnWM_IME_COMPOSITION (HWND hWnd, LParam lparam);}; void cime :: disableime () {while (importKeyboardLayout (0))) ActivateKeyboardLayout ((hkl) hkl_next, 0); // If IME is opened by looping to the next closure g_bime = false; g_szcompstr [0] = 0; g_szcompreadstr [0] = 0; g_nimecursor = 0; g_szimename [0] = 0; g_szcandlist [0] = 0;} void cime :: enableime () {g_bime = true;} void cime :: NextIme () {if (! g_bIme) return; ActivateKeyboardLayout ((HKL) HKL_NEXT, 0);} void CIme :: SharpIme (HWND hWnd) {ImmSimulateHotKey (hWnd, IME_CHOTKEY_SHAPE_TOGGLE);} void CIme :: SymbolIme (HWND hWnd) { Immsimulatehotkey (hwnd, IME_CHOTKEY_SYMBOL_TOGGLE);} void cime :: converTcandList (CandidateList * pcandlist, char * pszcandlist) // Convert Candidat ELIST to a string, / t separate each {Unsigned Int i; if (pcandlist-> dwselection) {pszcandlist [0] = 0; return;} // Total} // Total number, Microsoft Pinyin The second time to select the word table, then press PageDown, and will exit the selected word status, start a new input // but Microsoft Pinyin's own IME window can solve this problem, it is estimated that Microsoft Pinyin is implemented. More interface, so I use this less standard data // I can't solve this problem now, and I have rarely encountered this in actual use, and other standard input methods will not cause this BUG / / Non-standard input method estimates less interfaces, so it should not cause this bug for (i = 0; (i
= '.'; // use '.' Separate strcpy (pszcandlist, (char *) pcandlist pcandlist-> dwoffset [pcandlist-> dwselection i]); // Each actual content pszcandlist = strlen (pszcandlist) * Pszcandlist = '/ t'; // Idle between '/ T' Separation} * (pszcandlist - 1) = 0; // Central, and override the last '/ t'} BOOL CIME: ONWM_INPUTLANGCHANGEREQUEST If IME is prohibited, if IME is prohibited, the window function should return 0, otherwise DefWindowProc will open the input method} BOOL CIME: ONWM_INPUTLANGCHANGE (HWND HWND) // IME Change {HKL HKL = GetKeyboardLayout (0 ); if (ImmIsIME (hKL)) {hIMC hIMC = ImmGetContext (hWnd); ImmEscape (hKL, hIMC, IME_ESC_IME_NAME, g_szImeName); // get a new input name DWORD dwConversion, dwSentence; ImmGetConversionStatus (hIMC, & dwConversion, & dwSentence); ? g_bImeSharp = (dwConversion & IME_CMODE_FULLSHAPE) true: false; // get the whole angle mark g_bImeSymbol = (dwConversion & IME_CMODE_SYMBOL) true:? false; // get Chinese punctuation mark ImmReleaseContext (hWnd, hIMC);} else // English input g_szImeName [ 0] = 0; Return False; // Always return false because window letters are required DefWindowProc number call processing continues} bool CIme :: OnWM_IME_NOTIFY (HWND hWnd, WPARAM wParam) {HIMC hIMC; DWORD dwSize; DWORD dwConversion, dwSentence; switch (wParam) {case IMN_SETCONVERSIONMODE: // full / half width, / English punctuation change hIMC = ImmGetContext (hWnd); ImmGetConversionStatus (hIMC, & dwConversion, & dwSentence); g_bImeSharp = (dwConversion & IME_CMODE_FULLSHAPE) true: false; g_bImeSymbol = (dwConversion & IME_CMODE_SYMBOL) true:?? false; ImmReleaseContext (hWnd, hIMC); break;
Case IMN_OpenCandidate: // Enter the Selection Status Case IMN_CHANGECANDIDATE: / / Selection Letter Himc = ImmgetContext (HWND); if (g_lpcandlist) {GlobalFree ((Handle) g_lpcandlist); g_lpcandlist = null;} // Release the previous selection word table if (dwSize = ImmGetCandidateList (hIMC, 0, NULL, 0)) {g_lpCandList = (LPCANDIDATELIST) GlobalAlloc (GPTR, dwSize); if (g_lpCandList) ImmGetCandidateList (hIMC, 0, g_lpCandList, dwSize);} // get new selected word table ImmReleaseContext (hWnd, hIMC); if (g_lpCandList) ConvertCandList (g_lpCandList, g_szCandList); // table finishing selected word clusters break; case IMN_CLOSECANDIDATE: // Close the selected word list if (g_lpCandList) {GlobalFree ((HANDLE ) g_lpcandlist); g_lpcandlist = NULL;} // Release g_szcandlist [0] = 0; Break;} return true; // Always return TRUE to prevent IME window from opening} bool cime :: onwm_ime_composition (hwnd hwnd, lparam lparam) / / Enter change {HIMC HIMC; DWORD DWSIZE; HIMC = ImmgetCont ext (hWnd); if (lParam & GCS_COMPSTR) {dwSize = ImmGetCompositionString (hIMC, GCS_COMPSTR, (void *) g_szCompStr, sizeof (g_szCompStr)); g_szCompStr [dwSize] = 0;} // made szCompStr if (lParam & GCS_COMPREADSTR) {dwSize = ImmGetCompositionString (hIMC, GCS_COMPREADSTR, (void *) g_szCompReadStr, sizeof (g_szCompReadStr)); g_szCompReadStr [dwSize] = 0;} // made szCompReadStr if (lParam & GCS_CURSORPOS) {g_nImeCursor = 0xffff & ImmGetCompositionString (hIMC, GCS_CURSORPOS, NULL, 0);} // Get Nimecursor if (LParam & GCS_Resultstr) {Unsigned Char Str [MAX_PATH]; DWSIZE =