Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

switch input field to write a different language

Status
Not open for further replies.

SalehKiswani

IS-IT--Management
Jul 16, 2011
60
hello everybody,
I have this simple form which have some input fields.
the case is I have first field to input english name and the second field to input arabic name.

now the user name has to switch the language to input the arabic field by pressing the suitable hot keys.

Is there a way to switch to the required language without pressing the hot keys?

Iam using windows XP proffessional, clarin 6.3

THank you in advance.
 
Hi!

I assume you are talking about the language of the keyboard. I am not that knowledgeable about it but if changing the character set will help you could set the font & character set for that TEXT/ENTRY control.

If that does not work ::

On EVENT:Selected of the Arabic control ::

Code:
  ?<ArabicColumnName>{PROP:Touched} = True ! this will force an EVENT:Accepted for the control every time you exit this control

  SYSTEM{PROP:CharSet} = CHARSET:Arabic  ! 178

On EVENT:Accepted of the Arabic control ::

Code:
  SYSTEM{PROP:CharSet} = CHARSET:Ansi  ! 0

If changing the Character set is not enough you may need to use API's to change the keyboard layout at run time. Get back to me if you need this since I need to research this.

Regards
 
Thank you ShankarJ for your response as usual.

Yes Iam talking about the language of the keyboard.

I agree with you that it is mostly an API issue , I did some tests but it didnt work .

In my keyboard I press Left ALT+Shift to write in arabic , again I press the same buttons to write in English.

I hope this can give an indicator.

lots of thanks


 
Hi!

Did you try changing the Charset property?

Could you post the window layout of those two controls - the English & the Arabic one?

Regards
 
Hello ,
yes I tried that but didnt work.
Here is a screen shot of the window layout.

screen.jpg


thank you
 
Hi!

I want the window structure in text format i.e. press the ellipsis button, copy & paste that. Why? It looks like you have not set certain thinks like Layout to allow Right to Left entry for the Arabic control.

Regards
 
hello,
this the window structure... thank you

QuickWindow WINDOW('Window'),AT(,,260,160),FONT('MS Sans Serif',8,,FONT:regular),CENTER,IMM,HLP('Main'), |
SYSTEM,GRAY,RESIZE
TEXT,AT(67,29,129,10),USE(eng),#ORIG(eng)
TEXT,AT(69,76,129,10),USE(arb),SINGLE,LAYOUT(1),#ORIG(arb)
BUTTON('&OK'),AT(207,142,49,14),USE(?Ok),FLAT,LEFT,MSG('Accept operation'),TIP('Accept Operation'), |
ICON('WAOK.ICO'),#SEQ(1),#ORIG(?Ok)
END

 
Hi!

This is what I have done so far. It works but it seems to create extra languages for the language bar.

Code:
        program

        map
          MODULE('WINAPI')
            SJ_GetKeyboardLayoutName(LONG pwszKLID),BOOL,PROC,PASCAL,NAME('GetKeyboardLayoutNameA')
            SJ_LoadKeyboardLayout(LONG pwszKLID, ULONG xFlags),LONG,PROC,PASCAL,NAME('LoadKeyboardLayoutA')
            SJ_UnLoadKeyboardLayout(LONG xhkl),BOOL,PROC,PASCAL,NAME('UnloadKeyboardLayout')
            SJ_GetLastError(),UNSIGNED,PASCAL,NAME('GetLastError')
          END
        end

EnglishString                STRING(60)
ArabicString                 STRING(60)

KeyBoardName                 CSTRING(255)
KB_Addr                      LONG(0)
Err                          LONG(0)

KLF_ACTIVATE                 EQUATE(1)
KLF_REPLACELANG              EQUATE(16)

Arb_Eng                      BYTE(0)
ArabicKeyboard               EQUATE('00000401')
EnglishKeyboard              EQUATE('00000409')
Eng_HKL                      LONG
Arb_HKL                      LONG

Window WINDOW('Keyboard Language Test'),AT(,,164,90),FONT('Arial', 8,, FONT:bold),GRAY,WALLPAPER('BROWN.JPG'), Tiled
    PROMPT('In English'), AT(3,6), USE(?Prompt:EnglishString), TRN
    ENTRY(@S60), AT(36,6,121,10), USE(EnglishString), LEFT(1)
    PROMPT('In Arabic'), AT(3,21), USE(?Prompt:ArabicString), TRN
    ENTRY(@S60), AT(36,21,121,10), USE(ArabicString), LAYOUT(1), FONT('Andalus', 9,,, CHARSET:ARABIC)
    STRING(@S255), AT(2,39,161), USE(KeyBoardName), FONT(,, COLOR:Red), CENTER
    BUTTON('&Get Keyboard Layout'), AT(3,56,84,14), CURSOR('finger.cur'), USE(?GetLayout), LEFT
    BUTTON('&Toggle Keyboard Layout'), AT(3,73,84,14), CURSOR('finger.cur'), USE(?SetLayout), LEFT
    BUTTON('&Close'), AT(110,73,48,14), CURSOR('finger.cur'), USE(?Close), ICON('WACANCEL.ICO'), |
        LEFT
 END

  CODE

  OPEN(Window)

  DISPLAY()

  ACCEPT
    CASE EVENT()
    OF EVENT:CloseWindow
      BREAK
      
    OF EVENT:Accepted
      CASE FIELD()
      OF ?GetLayout
        KB_Addr = ADDRESS(KeyBoardName)
        IF SJ_GetKeyboardLayoutName(KB_Addr) > 0
           DISPLAY(?KeyBoardName)
        ELSE   
           Err = SJ_GetLastError() ; IF Err THEN MESSAGE('Error = ' & Err).
        END

      OF ?SetLayout
        Arb_Eng = 1 - Arb_Eng
        IF Arb_Eng
           KeyBoardName = ArabicKeyboard
        ELSE   
           KeyBoardName = EnglishKeyboard  ! UK
        END   
        KB_Addr = ADDRESS(KeyBoardName) ; KeyBoardName = CLIP(KeyBoardName) & '<0>'
        HKL# = SJ_LoadKeyBoardLayout(KB_Addr, KLF_ACTIVATE)
        IF HKL# > 0
           MESSAGE(HKL#)
           IF Arb_Eng THEN Arb_HKL = HKL# ELSE Eng_HKL = HKL#.
        ELSE
           Err = SJ_GetLastError() ; MESSAGE('Error = ' & Err)
        END
        POST(EVENT:Accepted, ?GetLayout)
        
      OF ?Close
        IF Eng_HKL
           IF SJ_UnLoadKeyBoardLayout(Eng_HKL) > 0
           ELSE
              Err = SJ_GetLastError() ; MESSAGE('Error = ' & Err)
           END
        END

        IF Arb_HKL
           IF SJ_UnLoadKeyBoardLayout(Arb_HKL) > 0
           ELSE
              Err = SJ_GetLastError() ; MESSAGE('Error = ' & Err)
           END
        END

        BREAK
      END
    END
  END

  CLOSE(Window)

  RETURN

Regards
 
well done shankar. it worked fine , just I changed one thing that I changed the control type to Text Field instead of Entry field because arabic charachters doesnt show properly in Entry field (letters will appear separate) and I changed the font to be more clear. nothing else I changed.
Here is the screen layout:
Code:
Window WINDOW('Keyboard Language Test'),AT(,,164,90),FONT('Arial',12,,FONT:bold),WALLPAPER('BROWN.JPG'), |
         TILED,GRAY
       PROMPT('In English'),AT(3,6),USE(?Prompt:EnglishString),TRN
       text,AT(36,6,121,10),USE(EnglishString),LEFT(1)
       PROMPT('In Arabic'),AT(3,21),USE(?Prompt:ArabicString),TRN
       text,AT(36,21,121,10),USE(ArabicString),FONT('Arabic Transparent',12,,FONT:regular,CHARSET:ARABIC),LAYOUT(1)
       STRING(@S255),AT(2,39,161,),USE(KeyBoardName),CENTER,FONT(,,COLOR:Black,)
       BUTTON('&Get Keyboard Layout'),AT(3,56,84,14),USE(?GetLayout),LEFT,CURSOR('finger.cur')
       BUTTON('&Toggle Keyboard Layout'),AT(3,73,84,14),USE(?SetLayout),LEFT,CURSOR('finger.cur')
       BUTTON('&Close'),AT(110,73,48,14),USE(?Close),LEFT,CURSOR('finger.cur'),ICON('WACANCEL.ICO')
     END
and this is a screen shot of a successful test
01.jpg



Thank you for your help
 
Hi!

When you use a Text Box as an Entry control, you need to use the SINGLE attribute to prevent the user from pressing <Enter> which will insert the CRLF (<13,10>) characters.

Did you check your Language Bar in Windows after running this app? Were new Languages created in that? If so, you have to fine tune the equates, ArabicKeyboard EQUATE('00000401') & EnglishKeyboard EQUATE('00000409') to the correct values for sub-language in the first 4 characters.

Good luck.

Regards
 
Hello,
yes. the Language Bar in Windows is changinging according to the button press.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top