Results 1 to 12 of 12

Thread: Language Change!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Greece
    Posts
    11

    Question

    Does anybody outthere knows how can i change the language with vb or Api code as i change it with ALT-TAB?
    Charis from GRE
    VB6 Enterprise

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    use SendKeys and send Alt+Tab in combination.
    Code:
    SendKeys "%{F4}"
    I forgot the key for name for Tab.
    gl,
    D!m


    [Edited by Dim on 07-17-2000 at 12:02 AM]
    Dim

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Greece
    Posts
    11

    Wink

    And if is not Alt-Tab?In many computers it may change with Shift+Alt.That's way i want to change it throuth Api in order to change the language whatever the combination is...
    Now, Can u halp me?
    Charis from GRE
    VB6 Enterprise

  4. #4
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    Exclamation Gurus where are you?

    It's a very interesting thing.
    I need it too.

  5. #5
    New Member
    Join Date
    May 2000
    Posts
    15

    Cool

    i thing i got the answer to that

    sendkeys does NOT change the keyboard layout

    -------->
    try the following:

    create a new project
    add 2 command keys, 1 listbox and 1 textbox
    put the following code in the code section

    '<----form1--->
    'Form1 add Listbox "list1" , Textbox "text1"
    'Command1 "Command1.Caption =English "
    'Command2 "Command2.Caption =arabic "

    Private Sub Form_Load()
    kbdList = GetKeyboardLayoutList(0, 0)
    List1.Clear
    List1.AddItem "Number of Keyboard installed: " & kbdList
    For x = 1 To kbdList
    ActiveKbd = ActivateKeyboardLayout(HKL_NEXT, 0)
    If Right(Hex(ActiveKbd), 1) = 1 Then
    ArabicKbd = ActiveKbd
    ElseIf Right(Hex(ActiveKbd), 1) = 9 Then
    EnglishKbd = ActiveKbd
    End If
    Next x
    End Sub

    Private Sub Command1_Click()

    ActiveKbd = ActivateKeyboardLayout(EnglishKbd, 0)
    List1.AddItem "Active Keyboard is: " & EnglishKbd
    Text1.SetFocus
    Text1.Alignment = 0
    Text1.RightToLeft = False

    End Sub
    Private Sub Command2_Click()
    ActiveKbd = ActivateKeyboardLayout(ArabicKbd, 0)
    List1.AddItem "Active Keyboard is: " & ArabicKbd
    Text1.Alignment = 1
    Text1.RightToLeft = True
    Text1.SetFocus
    End Sub


    -----------

    then add a module

    put the following code in it

    '<------ module1.bas----->
    'Add This code in a Moduel.bas file
    Declare Function GetKeyboardLayoutList Lib "user32.dll" (ByVal nBuff As Integer, ByVal lpList As Long) As Long
    Declare Function GetKeyboardLayout Lib "user32.dll" (ByVal dwLayout As Long) As Long
    Declare Function ActivateKeyboardLayout Lib "user32.dll" (ByVal HKL As Long, Flag As Boolean) As Long
    Declare Function LoadKeyboardLayout Lib "user32.dll" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As Long, Flag As Boolean) As Long
    Declare Function GetKeyboardLayoutName Lib "user32.dll" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As Long) As Long
    Global kbdList As Long
    Global ArabicKbd As Long
    Global EnglishKbd As Long
    Global kbdLayout As Long



    ----------------------------------------------
    ----------------------------------------------
    this code worked excellent with me

    try it and let me know if it worked



    zdocteur



  6. #6
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Zdocteur!

    This code work great. I was looking for something like this last week to help Tiovital.

    You only missing one constant which you did not declare in your example. It was HKL_NEXT.

    I hope you don't mind, but I fixed your code up and so you only need to drop it into a form.

    The following is Zdocteur's Code. Drop two command buttons, a textbox and a listbox on to a form.
    Code:
    Option Explicit
    'Before running this example - you must have two language.
    'Go into [Control Panel-Regional Setting]
    'and add another language on the last tab
    
    Private Declare Function GetKeyboardLayoutList Lib "user32.dll" (ByVal nBuff As Integer, ByVal lpList As Long) As Long
    Private Declare Function GetKeyboardLayout Lib "user32.dll" (ByVal dwLayout As Long) As Long
    Private Declare Function ActivateKeyboardLayout Lib "user32.dll" (ByVal HKL As Long, Flag As Boolean) As Long
    Private Declare Function LoadKeyboardLayout Lib "user32.dll" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As Long, Flag As Boolean) As Long
    Private Declare Function GetKeyboardLayoutName Lib "user32.dll" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As Long) As Long
    Private lng_KeyboardList As Long
    Private lng_NonEnglish As Long
    Private lng_EnglishKbd As Long
    
    Private Const HKL_NEXT = 1
    
    
    Private Sub Form_Load()
        lng_KeyboardList = GetKeyboardLayoutList(0, 0)
        List1.Clear
        List1.AddItem "Number of Keyboard installed: " & lng_KeyboardList
        
        Dim int_X As Integer
        Dim lng_ActiveKeyBoard As Long
        For int_X = 1 To lng_KeyboardList
            lng_ActiveKeyBoard = ActivateKeyboardLayout(HKL_NEXT, 0)
            
            If Right(Hex(lng_ActiveKeyBoard), 1) = 1 Then
              lng_NonEnglish = lng_ActiveKeyBoard
            ElseIf Right(Hex(lng_ActiveKeyBoard), 1) = 9 Then
              lng_EnglishKbd = lng_ActiveKeyBoard
            End If
        Next
    End Sub
    
    Private Sub Command1_Click()
        Call ActivateKeyboardLayout(lng_EnglishKbd, 0)
        List1.AddItem "Active Keyboard is: " & lng_EnglishKbd
        Text1.Alignment = 0
        Text1.RightToLeft = False
        Text1.SetFocus
    End Sub
    
    Private Sub Command2_Click()
        Call ActivateKeyboardLayout(lng_NonEnglish, 0)
        List1.AddItem "Active Keyboard is: " & lng_NonEnglish
        Text1.Alignment = 1
        Text1.RightToLeft = True
        Text1.SetFocus
    End Sub
    [Edited by Nitro on 07-27-2000 at 08:45 PM]
    Chemically Formulated As:
    Dr. Nitro

  7. #7
    New Member
    Join Date
    May 2000
    Posts
    15

    Red face

    its okie Nitro

    i have one Q though(non VB-related)
    how to post code in in this forum in a way similar to the way you did, i.e. VB- style with colors and different allignments?

    zdocteur


  8. #8
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    use brackets [ ]
    example (you need to remove the _):
    [_code_]
    This is a code
    [/_code_]
    Results with:
    Code:
    This is a code
    For a complete list of all VB-code functions go to this link:
    http://forums.vb-world.net/index.php?action=bbcode

  9. #9
    New Member
    Join Date
    May 2000
    Posts
    15

    Cool

    Code:
    do
        code.write
        if this is correct then
             me.gotIt
             you.thanx
             exit do
         else
             you(also).thanx
             goto sleep
             think about it in the morning
         end if
    loop
    exit.browser
    zdocteur

  10. #10
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    zdocteur,
    Just for my info - whare did u find that sample?
    Regards

  11. #11
    New Member
    Join Date
    May 2000
    Posts
    15

    Red face

    Tiovital,
    it's posted here:
    http://www.vb4arab.com/ubb/Forum5/HTML/000020.html

    the site is:
    http://www.vb4arab.com
    it's an arabic-oriented VB site - a good resource for arabic programmers.
    regards

    zdocteur

  12. #12
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width