Prev Next

ActivateKeyboardLayout info  Overview  Group

The implementations of ActivateKeyboardLayout in Windows NT and Windows 95 are substantially different. To accommodate these differences, this reference page first presents the Windows NT implementation in its entirety, followed by the Windows 95 version.

    Windows NT:

The ActivateKeyboardLayout function activates a different keyboard layout and sets the active keyboard layout for the entire system rather than the calling thread.

HKL ActivateKeyboardLayout(

    HKL hkl,

// handle to keyboard layout

    UINT Flags 

// keyboard layout flags

   );

Parameters

hkl
Identifies the keyboard layout to be activated. The layout must have been loaded by a previous call to the LoadKeyboardLayout function. This parameter must be either the handle to a keyboard layout or one of the following values:

Value

Meaning

HKL_NEXT

Selects the next layout in the circular list of loaded layouts maintained by the system.

HKL_PREV

Selects the previous layout in the circular list of loaded layouts maintained by the system.

Flags
Specifies how the keyboard layout is to be activated. This parameter can be one of the following values:

Value

Meaning

KLF_REORDER

If this bit is set, the system’s circular list of loaded keyboard layouts is reordered. If this bit is not set, the list is rotated without a change of order. For example, if a user had an English layout active, as well as having French, German and Spanish layouts loaded (in that order), then activating the German layout with the KLF_REORDER bit set would produce the following order: German, English, French, Spanish. Activating the German layout without the KLF_REORDER bit set would produce the following order: German, Spanish, English, French.

If less than three keyboard layouts are loaded, the value of this flag is irrelevant.

KLF_UNLOADPREVIOUS

The previously active layout is unloaded.

Return Values

If the function succeeds, the return value is the previous keyboard layout handle. Otherwise, it is zero. To get extended error information, use the GetLastError function.

Remarks

Several keyboard layouts can be loaded at any one time, but only one is active at a time. Loading multiple keyboard layouts makes it possible to rapidly switch between layouts.

See Also

LoadKeyboardLayout, GetKeyboardLayoutName, UnloadKeyboardLayout 

    Windows 95

The ActivateKeyboardLayout function sets the input language for the current thread. This function accepts a keyboard layout handle that identifies a locale as well as the physical layout of the keyboard.

HKL ActivateKeyboardLayout(

    HKL hkl,

// handle to keyboard layout

    UINT Flags 

// keyboard layout flags

   );

Parameters

hkl
Handle to a keyboard layout or a zero-extended locale identifier. This parameter can be any valid keyboard layout handle obtained using the LoadKeyboardLayout or GetKeyboardLayoutList function or one of the following values:

Value

Meaning

HKL_NEXT

Selects the next layout in the keyboard layouts list maintained by the system.

HKL_PREV

Selects the previous layout in the keyboards layout list maintained by the system.

Flags
Specifies the keyboard layout flags. The value of this parameter can be:

Value

Meaning

KLF_REORDER

Reorders the keyboard layouts list by moving the given keyboard layout handle to the head of the list. If this value is not given, the list is rotated without a change of order. For example, if a user had an English layout active, as well as having French, German and Spanish layouts loaded (in that order), then activating the German layout with the KLF_REORDER bit set would produce the following order: German, English, French, Spanish. Activating the German layout without the KLF_REORDER value set would produce the following order: German, Spanish, English, French.

Return Values

If the function succeeds, the return value is the previous keyboard layout handle. Otherwise, it is zero. To get extended error information, use the GetLastError function.

Remarks

Several keyboard layouts can be loaded at any one time, but only one is active at a time. Loading multiple keyboard layouts makes it possible to rapidly switch between layouts.

An application can create a valid keyboard layout handle by setting the high word to zero and the low word to a locale identifier. Using such keyboard layout handles changes the input language without affecting the physical layout.

When multiple input method editors (IMEs) are allowed for each locale, passing in a keyboard layout handle in which the high word (the device handle) is zero activates the first IME in the list “belonging” to the locale.

See Also

LoadKeyboardLayout, GetKeyboardLayoutName, UnloadKeyboardLayout