Jalaj P. Jha Technical & Miscellaneous Ramblings

16Apr/0711




Switching IME during runtime

Input Method Editor (IME) provide users an efficient way to key in texts other than the default Latin text.

ime.jpg

When the user has to switch between local language and the English "Advanced Key Settings" allow rapid switching.

imekey.jpg

But what if a single form contains multiple form elements, some of which expect input in local language and rest in English. Is it fair to burden user with the requirement to switch IME each time he changes field for input or rectification?

imeoff.jpg

Of course not! There needs to be some way out... and there is...

I assume here that you are using controls from "Micosoft Forms 2.0 Object Library" for Unicode character inputs. The form controls expecting user input from IME as TextBox, ComboBox exposes a property namely IMEMode which can be modified at runtime to relieve users from manually changing language settings.

As shown above there are two textboxes one of which expects input in lacal language while the other in English. Place codes as below for the GotFocus event of the controls and you are done.

Private Sub TextBox1_GotFocus()

    TextBox1.IMEMode = fmIMEModeOn

End Sub

Private Sub TextBox2_GotFocus()

    TextBox2.IMEMode = fmIMEModeOff

End Sub

Setting the properties as above ensures that IME works only on Controls where it is expected to.


FootNote : This post is in response to comment by Phil on the post Storing Unicode Data in Databases. Got any such problem please post on any relevant page or on page Ides ?. I would try to post solution and in the process would learn a few new things. After all learning never stops...

Comments (11) Trackbacks (1)
  1. I really don’t know how to Thank you!!! Excellent…way to process IME input !!!

    FULL FIDA for you…

    Thanks a Lot..

  2. Hey Don’t mistake FIDA…(I ment to say) IM VERY GREATFUL…..for your HELP…..

  3. Hello…

    Is there a possiblity to Assigin one Locale to one TextBox..just imagine there is a form where you have to input.. 3 different languages…and each Textbox..has to be assigned to different…Languages..???

    regards

  4. Hi Phil,
    Thanks!

    About assigning multiple IMEs to multiple textboxes… Yes it should be possible… I was thinking of it while publishing this post but decided to defer it for later sometime.

    http://msdn2.microsoft.com/en-us/library/ms776076.aspx list a range of functions for working with IME… which might faciliate the task…

  5. Hi..

    Nice Info..Thanks Very Much…Kindly let me know..if you do modification..(ofcourse this is my favourit spot which i visit daily).

    regards

  6. I am having a problem with “Micosoft Forms 2.0 Object Library” and TextBox1.IMEMode = fmIMEModeOn I find some funny characters appear. Well Im trying to input Arabic(Egypt) but I don’t see the expected characters input. Even if I select keyboard manually I don’t see the desired output. when i select Keyboard Egypt for TextBox1.IMEMode = fmIMEModeOn only …. …. appears I really don’t know how to solve this problem.

  7. Hi Phil,

    First of all please check if this problem is just with the VB Form or the problem is also visible when using IME to type in other application (supporting unicode) as MS Word, Wordpad.

    If other application too don’t work then the problem is due to a missing font. Try to trace a PC where IME is working fine and check for the fonts installed there.

  8. I have checked this sir. on the same form if i put ordinary text box instead of “Micosoft Forms 2.0 Object Library” it works very well but i want to change IME which will not be possible. Other application such as WordPad and MS-Word work fine so its not the problem with the font. I even tried the same issue on a different machine. Again the result is same. I only gives … …. on text box when IME is on.

  9. Hello Sir..

    Its always joy visiting your website…by the way…any update on this issue??? of IME not changing or Arabic characters not appearing properly..??? I shall be greatful if you can post a new sample for this….

  10. Google IME download in my window vista has loaded the Application but it fails to launch the IME transliteration pad. If clicked the Application restarts loding the same application. Tell, how solve please if you can.

    • Sorry but I have no idea for Vista. It works fine for my XP/Win7. Though it’s not that there can’t be any problem. One of my friends has troble installing it on his XP!… Will check if I get any solution to your problem.


Leave a comment