Shielding Chinese Input method in WinForm

Source: Internet
Author: User

In the development of WinForm, there are sometimes special requirements. For example: In a form to completely block the Chinese input method, so that it can not switch to Chinese input, can not be entered in Chinese.

The problem looks simple and is not as simple as it might seem. Below, I do a few of the experiments listed in turn, you will find that in fact, it is still difficult to achieve.

Experiment One:

1, the new project, the establishment of two form, respectively, Form1, Form2. Form1 is the start form.

2. There is a TextBox and a button on the Form1.

Click the button to execute the following statement

Me.hide ()

Form2.show ()

3, Form2 has a textbox,textbox of the IMEMode property set to close, meaning to turn off input mode.

Execute the following statement in the Form2 formclosed event.

Form1.show ()

OK, now to test the experiment. Well, unfortunately, in the Form2 in the textbox is very smooth switch the Chinese input method, entered the Chinese. The test failed.

Experiment Two:

Continue to experiment one, find the relevant data, found that there is a inputlanguagechanging event, seems to be able to control the input method of the switch.

4, add the following code in the Inputlanguagechanging event of the Form2 textbox

E.cancel = True

To test. Seemingly successful, according to the test, the Form2 in the textbox can not switch the input method.

Why does it seem like it? We'll test it again, and we'll have a problem.

First in the Form1 in the textbox to switch to Chinese input method. Then click on the button, switch to Form2, you ctrl+space, found in the textbox in Form2 appeared familiar with the Chinese input method. Oh, experiment II can not be counted as successful.

Why does the analysis experiment two not succeed. I think the key is to switch to Form2 before I have switched to Chinese input method. So what if you pin the input method to the default input method of the system before switching Form2?

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.