private bool setIME(bool mode) { IntPtr hWnd = IntPtr.Zero; //hWnd = GetActiveWindow(); hWnd = textBox1.Handle; if (hWnd == IntPtr.Zero) { //Can't find ActiveWindow return false; } IntPtr context = IntPtr.Zero; try { context = ImmGetContext(hWnd); //get IMEContext if (mode == true) { //get IMEStatus //if(ImmGetOpenStatus(IntPtr.Zero)){ // System.Windows.Forms.MessageBox.Show ("IME has be Opened"); //} // open IME return ImmSetOpenStatus(context, true); // IME on } else if (mode == false) { //get IMEStatus if (ImmGetOpenStatus(context)) { System.Windows.Forms.MessageBox.Show("IME has be Opened"); } // close IME(direct input for Alphabet and Number) bool immSetOpenStatus = ImmSetOpenStatus(context, false); //IntPtr immAssociateContext = ImmAssociateContext(hWnd, context); return immSetOpenStatus; // IME off } } finally { if (context != IntPtr.Zero) { ImmReleaseContext(hWnd, context); //Release IMEContext } } return false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)