To disable the Input Method in winform, set the following elements:
1. Add E. Cancel = true to the winform inputlanguagechanging event.
2. Register a keyboard event with the form (Form attribute)
Note: If you only need to block the system input method and have the function of switching the input method (system switching will cause some programs to become stuck), add "Code for switching the input method" to the input1_agechanging function ", the code for switching the input method cannot be added elsewhere. Otherwise, the floating window of the input method is inconsistent with that of the Input Method icon in the lower right corner of the system. Because the "Code for switching the input method" only controls the floating window of the input method, in the lower-right corner, the input method icon is switched Based on the floating window value of the input method. The code for switching the input method is as follows:
Private void mainform_input%agechanging (Object sender, input%agechangingeventargs E)
{
// The Program prohibits the transfer of messages from the input method to Windows.
E. Cancel = true;
Int icountlan = inputlanguage. installedinputages. count;
// Obtain the serial number iflaginputlan of the current Input Method
For (INT I = 0; I <inputlanguage. installedinputages. Count; I ++)
{
If (inputlanguage. currentinputlanguage. layoutname = inputlanguage. installedinputages [I]. layoutname)
{
Iflaginputlan = I;
Break;
}
}
// Obtain the serial number iflaginputlan of the next Input Method
If (iflaginputlan + 1)> = icountlan)
{
Iflaginputlan = 0;
}
Else
{
Iflaginputlan ++;
}
// Set the Input Method
Inputlanguage. currentinputlanguage = inputlanguage. installedinputlanguages ages [iflaginputlan];
}