Click here to Skip to main content
13,802,326 members
Click here to Skip to main content
Add your own
alternative version


21 bookmarked
Posted 10 May 2003

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


<h0>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 !

You may also be interested in...

Comments and Discussions

GeneralMSDN sample Pin
Fisico5-Dec-05 22:03
memberFisico5-Dec-05 22:03 
QuestionSimpler Method Pin
shmulyeng15-Nov-05 11:48
membershmulyeng15-Nov-05 11:48 
AnswerRe: Simpler Method Pin
Senthil Kumar U18-Jul-06 23:35
memberSenthil Kumar U18-Jul-06 23:35 
AnswerRe: Simpler Method Pin
Nader Al Khatib1-Jul-07 12:10
memberNader Al Khatib1-Jul-07 12:10 
GeneralMake Dos to Win Pin
Y_R27-Mar-05 11:57
memberY_R27-Mar-05 11:57 
GeneralNeed help Pin
percyvimal25-Nov-03 22:08
memberpercyvimal25-Nov-03 22:08 
GeneralActivateKeyboardLayout( ) Pin
Anonymous15-Oct-03 0:13
memberAnonymous15-Oct-03 0:13 
GeneralThe Best Solution For This Matter Pin
Yoavf7-Oct-03 0:09
memberYoavf7-Oct-03 0:09 
GeneralTo moshe masas &amp; Boaz72 and to all Pin
Yoavf6-Oct-03 23:56
memberYoavf6-Oct-03 23:56 
GeneralRe: To moshe masas &amp; Boaz72 and to all Pin
Anonymous13-Oct-03 22:02
memberAnonymous13-Oct-03 22:02 
GeneralRe: To moshe masas & Boaz72 and to all Pin
moshe masas4-Nov-03 4:38
membermoshe masas4-Nov-03 4:38 
GeneralRe: To moshe masas &amp; Boaz72 and to all Pin
Anonymous6-Nov-03 5:34
memberAnonymous6-Nov-03 5:34 
GeneralAlternative Solution Pin
Member 52199514-Aug-03 0:48
memberMember 52199514-Aug-03 0:48 
GeneralRe: Alternative Solution Pin
moshe masas31-Aug-03 1:36
membermoshe masas31-Aug-03 1:36 
GeneralRe: Alternative Solution Pin
boaz7231-Aug-03 9:55
sussboaz7231-Aug-03 9:55 
GeneralRe: Alternative Solution Pin
moshe masas2-Sep-03 4:31
membermoshe masas2-Sep-03 4:31 
GeneralNot working Pin
Didaa14-May-03 20:27
memberDidaa14-May-03 20:27 
GeneralRe: Not working Pin
moshe masas15-May-03 2:45
membermoshe masas15-May-03 2:45 
GeneralRe: Not working Pin
Didaa15-May-03 5:26
memberDidaa15-May-03 5:26 
GeneralRe: Not working Pin
moshe masas15-May-03 6:22
membermoshe masas15-May-03 6:22 
GeneralRe: Not working Pin
Anonymous16-May-03 4:58
memberAnonymous16-May-03 4:58 
GeneralRe: Not working Pin
moshe masas19-May-03 5:39
membermoshe masas19-May-03 5:39 
General&#1508;&#1512;&#1493;&#1497;&#1497;&#1511;&#1496; &#1502;&#1510;&#1495;&#1497;&#1511; Pin
Bengi12-May-03 2:11
memberBengi12-May-03 2:11 
Generalcabnet ?!? is this a joke !?! Pin
moshe masas12-May-03 4:09
membermoshe masas12-May-03 4:09 
GeneralRe: cabnet ?!? is this a joke !?! Pin
Bengi12-May-03 10:06
memberBengi12-May-03 10:06 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.181215.1 | Last Updated 11 May 2003
Article Copyright 2003 by moshe masas
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid