*** Activate keyboard for language specified if !empty(this.InputLocaleId) goSysAPI.ActivateKeyboardLayout (this.InputLocaleId) endifIn my lost focus I do the opposite:
*** Restore original keyboard if !empty(this.InputLocaleId) goSysAPI.ActivateKeyboardLayout () endifNow you need to look at my goSysAPI.ActivateKeyboardLayout() method:
procedure ActivateKeyboardLayout (pcInputLocaleID) *** Saves the current input locale, and sets the new one. *** If no pcLocalId passed, restore previous layout. * Pass hex code as letters and numbers. * Leading 0s are supplied automatically. *** Here are some common language IDs. See Foxpro.H for more. * 409 = EN = English (United States) * C0C = FR = French (Canada) - Canadian Multilingual Standard * 1401 = AR = Arabic (Algeria) - Arabic (102) * 11009 = EN = English (Canada) - Canadian Multilingual Standard local lnN, lnHandle, lcInputLocaleID if !" LoadKeyboardLayout " $ this.RegisteredAPIs *** Register DLLs declare integer GetKeyboardLayout ; in User32 ; integer lnThreadId declare integer LoadKeyboardLayout ; in User32 ; string @lpctInputLocalIndentifier, ; integer Flags declare integer ActivateKeyboardLayout ; in User32 ; integer lnHandle, ; integer Flags this.RegisteredAPIs = this.RegisteredAPIs + ; "GetKeyboardLayout LoadKeyboardLayout ActivateKeyboardLayout " endif if empty(pcInputLocaleId) *** Restore previous locale ActivateKeyboardLayout (this.PrevInputLocaleHandle, 0) else *** Save current keyboard layout for restoring this.PrevInputLocaleHandle = GetKeyboardLayout (0) *** Set/Load new locale lcInputLocaleID = padl(pcInputLocaleID, 8, "0") *** Look for a handle to this language lnN = ascan(this.aInputLocales, lcInputLocaleID, 1, -1, 1, 8) if lnN = 0 *** Not found. First time for this language. Load it. #define KLF_ACTIVATE 0x00000001 #define KLF_SUBSTITUTE_OK 0x00000002 lnHandle = LoadKeyboardLayout (lcInputLocaleId, ; KLF_ACTIVATE + KLF_SUBSTITUTE_OK) *** Save handle for future use do Addrow with this, "aInputLocales", lcInputLocaleId, lnHandle else *** We already have a handle for this language. Just activate it. ActivateKeyboardLayout (this.aInputLocales[lnN,2], 0) endif endif returnThis may be a bit fancier than you need, but the guts are there.