[AccessD] Accent Marks Needed

MartyConnelly martyconnelly at shaw.ca
Thu Aug 26 14:08:03 CDT 2004


If you are going to get deeper into this.
Here are two rough code snippets to switch languages on the fly for data 
entry in Access.
One uses API calls, the other keyboard events.

The Canadian Government sometimes specifies bilingual French-English 
form data entry.
I dunno how to handle DBCS languages like Chinese Big 5. As they say, 
that is left for an exercise for the student.
You probably fiddle around with the IME.


Public Declare Function LoadKeyboardLayout Lib "user32" Alias _
"LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal Flags As Long) As 
Long

Private Declare Function ActivateKeyboardLayout Lib "user32" (ByVal HKL 
As Long, _
ByVal Flags As Long) As Long

Private Declare Function GetKeyboardLayoutName Lib "user32" Alias _
"GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long

Const KL_NAMELENGTH = 9

Sub testarabic()
Dim lRet As Long
'your language selection bar will have languages added if available on 
the machine.
 ' warning if  bar isn't visible on screen taskbar or floating version, 
you may have to go to control panel to reset
' to proper language desired.
   lRet = LoadKeyboardLayout("00000409", 1)     '   For English
   Debug.Print lRet
   lRet = ActivateKeyboardLayout("00000409", 0)
   Debug.Print lRet
   lRet = LoadKeyboardLayout("00000401", 1)    '   For Arabic
     Debug.Print lRet
   lRet = ActivateKeyboardLayout("00000401", 0)
   Debug.Print lRet
     lRet = LoadKeyboardLayout("00011009", 1)    '   For FrenchCanadian
     Debug.Print lRet
   lRet = ActivateKeyboardLayout("00011009", 0)
   Debug.Print lRet
End Sub

Sub resetenglish()
Dim lRet As Long
 lRet = LoadKeyboardLayout("00000409", 1)     '   For US English
   Debug.Print lRet
   lRet = ActivateKeyboardLayout("00000409", 0)
   Debug.Print lRet
End Sub

Sub whatiskeybd()
    Dim strName As String
    'Create a buffer
    strName = String(KL_NAMELENGTH, 0)
    'Get the keyboard layout name
    GetKeyboardLayoutName strName
    Debug.Print "Keyboard layout name: " &  strName
End Sub

-------------------------------------------------------------------

Alternate method for bilingual entry on textboxes
assumes you have only two languages on language bar
or you are using only one hot key switch

'http://www.microsoft.com/globaldev/handson/dev/Unicode-KbdsonWindows.pdf
'http://www.microsoft.com/globaldev/nlsweb/default.asp?submitted=40d

'Part of the file Win32api.txt:
'
'   VK_L VK_R - left and right Alt, Ctrl and Shift virtual keys.
'   Used only as parameters to GetAsyncKeyState() and GetKeyState().
'   No other API or message will distinguish left and right keys in this
'way.
'  /
Public Const VK_LSHIFT = &HA0
Public Const VK_RSHIFT = &HA1
Public Const VK_LCONTROL = &HA2
Public Const VK_RCONTROL = &HA3
Public Const VK_LMENU = &HA4
Public Const VK_RMENU = &HA5

'What a weird name for the Alt-key. but it does use the menu

Private Const VK_LWIN = &H5B 'Left window button
Private Const VK_RETURN = &HD  'ENTER key
Private Const VK_SHIFT = &H10 'SHIFT key
Private Const VK_CONTROL = &H11 'CTRL key
Private Const VK_MENU = &H12 'ALT key
Private Const VK_PAUSE = &H13 'PAUSE key
Private Const VK_CAPITAL = &H14 'CAPS LOCK key
Private Const VK_SNAPSHOT = &H2C  'Print Screen
Private Const VK_APPS = &H5D
         'Applications key on a Microsoft Natural Keyboard
'from http://support.microsoft.com/view/dev.asp?kb=242971

Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Private Const KEYEVENTF_KEYUP = &H2

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
    ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Sub ShiftToLanguage()
'use the following code inside form or focused window or textbox
'to simulate the Alt RightShift = key combination:

     ' then press and then release the AltRight RightShift key
     'order of pressing important
     keybd_event VK_RSHIFT, 0, 0, 0
      keybd_event VK_RMENU, 0, 0, 0
     
      
    keybd_event VK_RMENU, 0, KEYEVENTF_KEYUP, 0
'weird things happen if you don't up the shiftkey looks like capslock
'has been left on
   keybd_event VK_RSHIFT, 0, KEYEVENTF_KEYUP, 0
  Debug.Print "Shift"
  DoEvents

End Sub

Sub ShiftToLanguageBack()
'use the following code inside form or focused window or textbox
'to simulate the Alt RightShift = key combination:

     ' then press and then release the AltRight RightShift key
     'order of pressing important
     keybd_event VK_LSHIFT, 0, 0, 0
      keybd_event VK_LMENU, 0, 0, 0
     
      
    keybd_event VK_LMENU, 0, KEYEVENTF_KEYUP, 0
'weird things happen if you don't up the shiftkey looks like capslock
'has been left on
   keybd_event VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0
  Debug.Print "Shift Back"
  DoEvents

End Sub

Rocky Smolin - Beach Access Software wrote:

>Marty:
>
>Don't know exactly how I did it, but I got the alternate keyboard.  AND I
>can key the accent marks directly in an Access table now.
>
>Thanks to all
>
>Best,
>
>Rocky Smolin
>Beach Access Software
>http://www.e-z-mrp.com
>
>----- Original Message ----- 
>From: "MartyConnelly" <martyconnelly at shaw.ca>
>To: "Access Developers discussion and problem solving"
><accessd at databaseadvisors.com>
>Sent: Wednesday, August 25, 2004 12:07 AM
>Subject: Re: [AccessD] Accent Marks Needed
>
>
>  
>
>>Another Method
>>
>>Win XP Control Panel --> Regional Language Settings--> Languages
>>--Details --> Installed services
>> Add the Spanish Keyboard in addition to English.
>>
>>Other button option selections
>>
>>Language -choose to float Keyboard Language Bar on Screen as transparent
>>or in tasktray
>>I prefer floating bar rather cluttering TaskTray icon
>>
>>Key Settings choose a hotkey to switch language keyboard.
>>
>>This will give you a floating keyboard selection bar
>>
>>Defualt To change language keyboards when typing  toggle ALT - Right Shift
>>
>> You can also do this by VBA code. I have used to sense Keyboard
>>language state and switch between French or English Text boxes on same
>>    
>>
>form
>  
>
>>There are probably pictures of spanish keyboard mappings at
>>http://www.microsoft.com/globaldev
>>
>>Rocky Smolin - Beach Access Software wrote:
>>
>>    
>>
>>>Stuart:
>>>
>>>
>>>Thanks.  Works well in Word. But it doesn't seem to work the same when
>>>keying into a table.  Any ideas there?  It's the language tables in the
>>>      
>>>
>mdb
>  
>
>>>where I have to key all this Spanish.
>>>
>>>Rocky
>>>
>>>
>>>----- Original Message ----- 
>>>From: "Stuart McLachlan" <stuart at lexacorp.com.pg>
>>>To: "Access Developers discussion and problem solving"
>>><accessd at databaseadvisors.com>
>>>Sent: Tuesday, August 24, 2004 2:42 PM
>>>Subject: Re: [AccessD] Accent Marks Needed
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>On 24 Aug 2004 at 13:34, Rocky Smolin - Beach Access Software wrote:
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>>>I want to do the Spanish translation of my system, but I'm having a
>>>>>terrible time trying to figure out how to get the accent marks on the
>>>>>vowels.
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>Simplest solution I've found is to create text in Word and then cut and
>>>>paste.
>>>>
>>>>>From the Word Help:
>>>>To insert Press
>>>>à, è, ì, ò, ù
>>>>À, È, Ì, Ò, Ù CTRL+` (ACCENT GRAVE), the letter
>>>>
>>>>á, é, í, ó, ú, ý
>>>>Á, É, Í, Ó, Ú, Ý CTRL+' (APOSTROPHE), the letter
>>>>
>>>>â, ê, î, ô, û
>>>>Â, Ê, Î, Ô, Û CTRL+SHIFT+^ (CARET), the letter
>>>>
>>>>ã, ñ, õ
>>>>Ã, Ñ, Õ CTRL+SHIFT+~ (TILDE), the letter
>>>>ä, ë, ï, ö, ü, ÿ
>>>>
>>>>Ä, Ë, Ï, Ö, Ü, Y CTRL+SHIFT+: (COLON), the letter
>>>>
>>>>å, Å CTRL+SHIFT+@, a or A
>>>>
>>>>æ, Æ CTRL+SHIFT+&, a or A
>>>>
>>>>o, O CTRL+SHIFT+&, o or O
>>>>
>>>>ç, Ç CTRL+, (COMMA), c or C
>>>>
>>>>ð, Ð CTRL+' (APOSTROPHE), d or D
>>>>
>>>>ø, Ø CTRL+/, o or O
>>>>
>>>>¿ ALT+CTRL+SHIFT+?
>>>>
>>>>¡ ALT+CTRL+SHIFT+!
>>>>-- 
>>>>Stuart
>>>>
>>>>
>>>>-- 
>>>>_______________________________________________
>>>>AccessD mailing list
>>>>AccessD at databaseadvisors.com
>>>>http://databaseadvisors.com/mailman/listinfo/accessd
>>>>Website: http://www.databaseadvisors.com
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>
>>>      
>>>
>>-- 
>>Marty Connelly
>>Victoria, B.C.
>>Canada
>>
>>
>>
>>-- 
>>_______________________________________________
>>AccessD mailing list
>>AccessD at databaseadvisors.com
>>http://databaseadvisors.com/mailman/listinfo/accessd
>>Website: http://www.databaseadvisors.com
>>    
>>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list