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
);
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. |
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_SETFORPROCESS | Windows NT 5.0 and later: Activates the specified keyboard layout for the entire process and sends the WM_INPUTLANGCHANGE message to all threads in the current process. |
KLF_UNLOADPREVIOUS | The previously active layout is unloaded. |
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.
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.
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
);
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. |
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. |
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.
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.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
Keyboard Input Overview, Keyboard Input Functions, LoadKeyboardLayout, GetKeyboardLayoutName, UnloadKeyboardLayout