Limiting the languages of input

by Michael S. Kaplan, published on 2005/04/25 07:10 -04:00, original URI:

Windows 2000, XP, and Server 2003 have powerful support for the input of text. On a per thread level, you can designate the support of any language you want, whatsoever.

For some applications, this is not so good. One may want to block the ability to change the language.

The first line of defense in such cases is to cancel any attempt to change the input language to any language you do not like, either

This method is not so useful if the language needs to be limited for some fields but not for others. Say for example in a password field, if you wanted to block the IME since allowing an IME would allow people to view the password that you are masking. Or if you want to make sure the language is not the wrong one to being with. In those cases, you have to be a bit more clever. When you enter a control that needs the limitation, you can check the current input language, either

These methods allow you to sniff the input language and/or the actual keyboard being used, and if you do not like the current choice you can change it, either

to change the input language to one that is more acceptable to the application.

Make sure there is some indication to the user that the change has been made; it is very unintuitive to make the change without telling the user, since they may type thunking the input language has not changed, and the results will not meet with their expectations.

It is probably a really good idea to cache the GetKeyboardLayout or InputLanguage.CurrentInputLanguage results so that you can switch back to the original input language when they leave the control that needs the restriction (a temporary change is sometimes unintuitive, but at least explainable; not changing it back is not only unintuitive but also a little bit obnoxious for an application to do!).


This post brought to you by "฿" (U+0e3f, a.k.a. THAI CURRENCY SYMBOL BAHT)

no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day