C # form program blocking Input Method

Source: Internet
Author: User

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];
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.