Click here to Skip to main content
Click here to Skip to main content

Language Input Mode (mainly for hebrew programmers)

, 10 May 2003
Rate this:
Please Sign up or sign in to vote.
How to adjust the input in regard to the desired language mode


In my latest project - "Cabnet", I have implemented the language input mode keyboard for restricting the user just to Hebrew typing - the trick isn't to prevent unwanted letters but rather to adjust the keyboard at need.


Developers Target

As the title stated, this article is for mainly Hebrew developers. But in fact, any development which deal with multi-language issue, where the user has to press on Alt+Shift && Caps Lock for language mode input movement, is a legitimate client for the following lines. So, the title is no more than a misled road sign. Then why I did it that way? Local-patriotism? Maybe. But - listen - while most of the time Hebrew programmers must use English as communication tool - for one time only the whole world has to be a hebrewphile but hopefully not a hebrewphobe to read this article.

The problem

As a writer of many client applications - I used to be frustrated from the frequently necessity to change the keyboard input mode from Hebrew to English and vice versa.


While, usually it is useful to have this option - many times it is just irritating NEEDLESSLY.


Suppose the user has to type his name on edit box and the app's demand is ONLY for Hebrew (or other local language) form.


  1. Prevent unwanted letters.
  2. Automatically change the keyboard attribute to Hebrew input mode.
You could implement the first solution but it's more wise to fulfill the second approach - as I did.

Demo's Features

 void SetEnglishLanguage()
 void SetLanguageDynamic()
 void SetLocalLanguage()

How it works ?

As you probably know, the windows loop messaging contain three function:
One role of the TranslateMessage() function is to scan the state of the controls keys - because those states are the trigger factors for manipulation messages.

So, the trick is to hook the message before the translation process - if it is necessary, adjust the language mode by requesting the currently language setting and deactivate the caps lock - thus finally you could launch the built-in translation.

Snippet of code

BOOL CHebrewEdit::PreTranslateMessage(MSG* pMsg) 
    switch(pMsg->message) {

    case WM_KEYDOWN:

    return CEdit::PreTranslateMessage(pMsg);
Note : the CHebrewEdit name could be replaced by 'CArabicEdit', 'CChineseEdit' or for global name solution 'CLocalEdit'.

void CHebrewEdit::ValidateLanguage()
    int ks;
    BOOL caps;

    if (IsLanguageDynamic()) return;
    if (m_nLanguage == LANG_M_LOCAL)
    if (m_nLanguage == LANG_M_ENGLISH) {

        else ASSERT(FALSE);

        caps = (IsCapsSet() & 0x01);
    if (IsEnglishLanguage()) caps=!caps;

    if (caps) { // for capslock



Source Code

My source code implements only the edit box extension, although the code is simple and portable for other windows controls, or even for the whole process by hooking the input process, although it isn't much recommend if you eager to reach speed optimum and robustness (see: SetWindowsHookEx).


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

moshe masas
Web Developer
Israel Israel
I'm just a small brain connected to an un-limited
brains network, which lead directly to the top ten
giant minds. Which lead me to the
thought : who am i?
I am just a jerry-built god !

Comments and Discussions

GeneralMSDN sample PinmemberFisico5-Dec-05 21:03 
QuestionSimpler Method Pinmembershmulyeng15-Nov-05 10:48 
AnswerRe: Simpler Method PinmemberSenthil Kumar U18-Jul-06 22:35 
AnswerRe: Simpler Method PinmemberNader Al Khatib1-Jul-07 11:10 
GeneralMake Dos to Win PinmemberY_R27-Mar-05 10:57 
GeneralNeed help Pinmemberpercyvimal25-Nov-03 21:08 
GeneralActivateKeyboardLayout( ) PinsussAnonymous14-Oct-03 23:13 
GeneralThe Best Solution For This Matter PinmemberYoavf6-Oct-03 23:09 
GeneralTo moshe masas & Boaz72 and to all PinmemberYoavf6-Oct-03 22:56 
GeneralRe: To moshe masas & Boaz72 and to all PinsussAnonymous13-Oct-03 21:02 
GeneralRe: To moshe masas & Boaz72 and to all Pinmembermoshe masas4-Nov-03 3:38 
GeneralRe: To moshe masas & Boaz72 and to all PinsussAnonymous6-Nov-03 4:34 
GeneralAlternative Solution PinmemberBoaz7213-Aug-03 23:48 
GeneralRe: Alternative Solution Pinmembermoshe masas31-Aug-03 0:36 
GeneralRe: Alternative Solution Pinsussboaz7231-Aug-03 8:55 
GeneralRe: Alternative Solution Pinmembermoshe masas2-Sep-03 3:31 
GeneralNot working PinmemberDidaa14-May-03 19:27 
GeneralRe: Not working Pinmembermoshe masas15-May-03 1:45 
GeneralRe: Not working PinmemberDidaa15-May-03 4:26 
GeneralRe: Not working Pinmembermoshe masas15-May-03 5:22 
GeneralRe: Not working PinsussAnonymous16-May-03 3:58 
GeneralRe: Not working Pinmembermoshe masas19-May-03 4:39 
Generalפרוייקט מצחיק PinmemberBengi12-May-03 1:11 
Generalcabnet ?!? is this a joke !?! Pinmembermoshe masas12-May-03 3:09 
GeneralRe: cabnet ?!? is this a joke !?! PinmemberBengi12-May-03 9:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 11 May 2003
Article Copyright 2003 by moshe masas
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid