The implementations of LoadKeyboardLayout in Windows 95 and Windows NT are substantially different. To accommodate these differences, this reference page first presents the Windows 95 implementation in its entirety, followed by the Windows NT version.
The LoadKeyboardLayout function loads a new keyboard layout into the system. Several keyboard layouts can be loaded at a time, but only one per process is active at a time. Loading multiple keyboard layouts makes it possible to rapidly switch between layouts.
HKL LoadKeyboardLayout(
LPCTSTR pwszKLID, |
// name of layout to load |
UINT Flags |
// keyboard layout flags |
); |
Value |
Meaning |
KLF_ACTIVATE |
If the given layout is not already loaded, the function loads and activates the layout for the current thread, inserting the layout at the head of the keyboard layouts list in front of the previously active layout. If the layout is already loaded and the KLF_REORDER value is not given, the function simply rotates the keyboard layouts list, making the next layout the active layout. |
KLF_NOTELLSHELL |
Prevents a ShellProc hook procedure from receiving an HSHELL_LANGUAGE hook code when the new layout is loaded. This value is typically used when an application loads multiple layouts, one after another. Applying this value to all but the last layout delays the shells processing until all layouts have been added. |
KLF_REORDER |
Moves the given layout to the head of the keyboard layouts list, making that layout the active layout for the current thread. This value reorders the keyboard layouts list even if KLF_ACTIVATE is not given. |
KLF_REPLACELANG |
If the new layout has the same language identifier as a current layout, the new layout replaces the current one as the layout for that language. If this value is not given and the layouts have the same language identifiers, the current layout is not replaced and the function returns NULL. |
KLF_SUBSTITUTE_OK |
Substitues the given keyboard layout with another layout preferred by the user. The substitution occurs only if the registry key HKEY_CURRENT_USER\Keyboard Layout\Substitutes explicitly defines a substitution layout. For example, if the key includes the value name 00000409 with value 00010409, loading the U.S. English layout (00000409) causes the Dvorak U.S. English layout (00010409) to be loaded instead. The system uses KLF_SUBSTITUTE_OK when booting and it is recommended that all applications use this value too. |
If the function succeeds, the return value is the keyboard layout handle of the layout matched with the requested name or NULL if no matching keyboard is available. To get extended error information, call GetLastError.
If a layout is to be loaded with the same language as a previously loaded one and the KLF_REPLACELANG flag is not set, the call fails. Only one loaded layout may be associated with a given language. (It is acceptable for multiple IMEs to be loaded with associations to the same language.)
An application can and will typically want to load the default layout or IME for a language and can do so by specifying only a string version of the language identifier. If an application wants to load a specific layout or IME, it should read the registry to determine the specific layout identifier to pass to LoadKeyboardLayout. In this case, a request to activate the default keyboard layout handle for a locale will activate the first matching one. A specific IME should be activated using an explicit keyboard layout handle returned from one of GetKeyboardLayout, GetKeyboardLayoutList or LoadKeyboardLayout.
ActivateKeyboardLayout, GetKeyboardLayout, GetKeyboardLayoutName, MAKELANGID, UnloadKeyboardLayout
The LoadKeyboardLayout function loads a keyboard layout.
HKL LoadKeyboardLayout(
LPCTSTR pwszKLID, |
// address of buffer for layout name |
UINT Flags |
// keyboard layout flags |
); |
Value |
Meaning |
KLF_ACTIVATE |
The function loads the layout if it is not already loaded, and activates it. This value activates the layout for the entire system not just the calling thread. |
KLF_REORDER |
This flag is meaningful only if the KLF_ACTIVATE flag is set and the layout is already loaded. If these conditions are met and the KLF_REORDER bit is set, the function removes the specified layout from its position in the systems circular list of loaded layouts, and places it at the head of the list as the active layout. |
If the KLF_ACTIVATE bit is set and the layout is loaded but the KLF_REORDER bit is not set, the function simply rotates the systems circular list of loaded layouts. | |
If the KLF_ACTIVATE flag is set and the layout is not already loaded, it is loaded as the active layout and inserted in the systems circular list of keyboard layouts ahead of the previously active layout. | |
KLF_SUBSTITUTE_OK |
The specified layout is looked up in the users profile (in the registry under the key HKEY_CURRENT_USER\Keyboard Layout\Substitutes) to find a substitution layout preferred by the user. For example, if there was a value in this section of name 00000409 equal to 00010409, loading the U.S. English layout (00000409) with the KLF_SUBSTITUTE_OK flag set would cause the Dvorak U.S. English layout (00010409) to be loaded. |
KLF_UNLOADPREVIOUS |
If KLF_ACTIVATE is specified, and the layout is loaded and activated successfully, the function unloads the previously active layout. Otherwise, the function ignores this flag. |
If the function succeeds, the return value is the handle of the keyboard layout.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Several keyboard layouts can be loaded at a time, but only one at a time is active. Loading multiple keyboard layouts makes it possible to switch rapidly between layouts.
ActivateKeyboardLayout, GetKeyboardLayoutName, UnloadKeyboardLayout
file: /Techref/os/win/api/win32/func/src/f53_14.htm, 11KB, , updated: 2000/4/7 11:19, local time: 2024/12/28 08:54,
18.218.119.140:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/Techref/os/win/api/win32/func/src/f53_14.htm"> LoadKeyboardLayout</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.