Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
English vs Chinese
Message
 
À
11/09/2005 23:19:35
Aaron K. Y. Chu
Health & Care Co. Ltd.
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01048606
Message ID:
01048633
Vues:
16
>Dear All,
>
>Is there any way to detect the user's input other than english, e.g. Chinese. If so, how many ways?
>
>One of the ways I can think of is to track the IME()... is that possible?

Here an exaple how to use some API functions to check and switch the Active Keyboard Layout:
#define KL_NAMELENGTH 9
#define HKL_NEXT      1
#define HKL_PREV      0

Declare INTEGER ActivateKeyboardLayout IN WIN32API INTEGER HKL, INTEGER Flags
Declare INTEGER GetKeyboardLayout      IN WIN32API INTEGER dwLayout
Declare INTEGER GetKeyboardLayoutName  IN WIN32API STRING @pwszKLID

STORE 0 TO lngCurrent_HKL, lngSwitched_HKL
STORE "" TO strCurrent_Buffer, strSwitched_Buffer

*Retrieves current handle to the keyboard layout
lngCurrent_HKL = GetKeyboardLayout(0)
   
*creates a buffers
STORE REPLICATE(CHR(0),KL_NAMELENGTH - 1) TO strCurrent_Buffer, strSwitched_Buffer
   
*Retrieves current name of the active keyboard layout
GetKeyboardLayoutName(@strCurrent_Buffer)
   
*Switches to the next keyboard layout
ActivateKeyboardLayout(HKL_NEXT, 0)
   
*-Retrieves "switched" handle to the keyboard layout
lngSwitched_HKL = GetKeyboardLayout(0)
   
*Retrieves "switched" name of the active keyboard layout
GetKeyboardLayoutName(@strSwitched_Buffer)
MESSAGEBOX("Keyboard layout was switched" +CHR(13) + "from " + strCurrent_Buffer + " to " + strSwitched_Buffer)
      
*Returns to the initial keyboard layout
ActivateKeyboardLayout(lngCurrent_HKL, 0)
It was taken from API-Guide So you can use it to check if the keyboard layout is diffenrent then 409 (English):
#define KL_NAMELENGTH 9
#define HKL_NEXT      1
#define HKL_PREV      0


? IsEnglish()


FUNCTION IsEnglish()

Declare INTEGER GetKeyboardLayout      IN WIN32API INTEGER dwLayout
Declare INTEGER GetKeyboardLayoutName  IN WIN32API STRING @pwszKLID

STORE  0 TO lngCurrent_HKL
STORE "" TO strCurrent_Buffer

*Retrieves current handle to the keyboard layout
lngCurrent_HKL = GetKeyboardLayout(0)
   
*creates a buffers
STORE REPLICATE(CHR(0),KL_NAMELENGTH - 1) TO strCurrent_Buffer

*Retrieves current name of the active keyboard layout
GetKeyboardLayoutName(@strCurrent_Buffer)
CLEAR DLLS GetKeyboardLayout, GetKeyboardLayoutName
RETURN (VAL(strCurrent_Buffer) == 409)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform