什么是ActivateKeyboardLayout

核心提示ActivateKeyboardLayout是一个为激活键盘布局提供服务的计算机函数。中文名ActivateKeyboardLayout函数功能激活键盘布局函数原型HKL ActivateKeyboardLayouthkl将被激活的键盘布局

最佳答案:

ActivateKeyboardLayout是一个为激活键盘布局提供服务的计算机函数。

详情介绍

ActivateKeyboardLayout是一个为激活键盘布局提供服务的计算机函数。

中文名
ActivateKeyboardLayout
函数功能
激活键盘布局
函数原型
HKL ActivateKeyboardLayout
hkl
将被激活的键盘布局的句柄

ActivateKeyboardLayout函数功能

激活键盘布局。该函数Windows NT和Windows 95中的实现有很大不同。本参考页中首先给出了完整的Windows NT的实现,下来又给出了Windows 95版本的实现,以便大家更好地了解二者的区别。在Windows NT中ActivateKeyboadLayout函数激活一种不同的键盘布局,同时在整个系统中而不仅仅是调用该函数的进程中将该键盘布局设为活动的。

ActivateKeyboardLayout函数原型

HKL ActivateKeyboardLayout( HKL hkl,UINT Flags);

ActivateKeyboardLayout参数

hkl:将被激活的键盘布局的句柄。在Windows NT/2000/XP下,该布局必须先调用LoadKeyboadLayout函数装入,该参数必须是键盘布局的句柄,或是如下的值中的一种:

HKL_NEXT(&H1):在系统保持的,己装入的布局的循环链表中,选择下一布局。

HKL_PREV(&H0):在系统保持的,已装入的布局的循环链表中,选择前一布局。

Flags:定义键盘布局如何被激活。该参数可取如下的一些值:

KLF_REORDER(&H8):若该位被设置,则已装入的键盘布局的循环链路表将被重新排序。若该位没有设置,则循环链路表的顺序不变。例如,若用户激活了英语键盘布局,同时依序装入了法语、德语、西班牙语键盘布局,然后通过设置KLF_REORDER位激活德语键盘布局,则会产生如下顺序:德语、英语、法语、西牙语键盘布局。若激活德语键盘布局时未设置KLF_REORDER(&H8)位,则产生如下的键盘布局的键盘布局序列:德语、西班牙语、英语、法语。若装入的键盘布局少于三种,则该标志域的值不起作用。

KLF_SETFORPROCESS(&H100):在Windows NT 5.0以上版本中使用。该参数用于整个进程中激活指定的键盘布,并向当前进程的所有线程发送WM_INPUTLANGCHANGE消息。

KLF_UNLOADPREVLOUS(&H4):卸载先前活动的键盘布局。此处无法使用此参数,可用UnloadKeyboardLayout 函数替代。

ActivateKeyboardLayout返回值

如果函数调用成功,返回值为前一键盘布局的句柄。否则,返回值为零。若要获得更多多错误信息,可调用GetLastError函数。

备注:在任一时刻可以装入多种键盘布局,但一次仅能激活一种布局。装入多种键盘布局使得可以快速地在多种布局之间切换。Windows 95 ACtivateKeyboadLayout函数为当前线程设置输入语言。该函数接受一个键盘布局句柄,该句柄标识键盘的一个局部的和物理布局。

速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:不支持;头文件:winuser.h;库文件:user32.lib。

ActivateKeyboardLayoutParameters

hkl HKLInput locale identifier to be activated.

The input locale identifier 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.

HKL_NEXT(&H1)

Selects the next locale identifier in the circular list of loaded locale identifiers maintained by the system.

HKL_PREV(&H0)

Selects the previous locale identifier in the circular list of loaded locale identifiers maintained by the system.

Flags UINTSpecifies how the input locale identifier is to be activated. This parameter can be one of the following values.

KLF_REORDER(0x00000008)

If this bit is set, the system's circular list of loaded locale identifiers is reordered by moving the locale identifier to the head of the list. If this bit is not set, the list is rotated without a change of order.

For example, if a user had an English locale identifier active, as well as having French, German, and Spanish locale identifiers loaded (in that order), then activating the German locale identifier with the KLF_REORDER bit set would produce the following order: German, English, French, Spanish. Activating the German locale identifier without the KLF_REORDER bit set would produce the following order: German, Spanish, English, French.

If less than three locale identifiers are loaded, the value of this flag is irrelevant.

KLF_RESET(0x40000000)

If set but KLF_SHIFTLOCK is not set, the Caps Lock state is turned off by pressing the Caps Lock key again. If set and KLF_SHIFTLOCK is also set, the Caps Lock state is turned off by pressing either SHIFT key.

These two methods are mutually exclusive, and the setting persists as part of the User's profile in the registry.

KLF_SETFORPROCESS(0x00000100)

Activates the specified locale identifier for the entire process and sends the WM_INPUTLANGCHANGE message to the current thread's Focus or Active window.

KLF_SHIFTLOCK(0x00010000)

This is used with KLF_RESET. See KLF_RESET for an explanation.

KLF_UNLOADPREVIOUS(不支持)

This flag is unsupported. Use the UnloadKeyboardLayout function instead.

ActivateKeyboardLayoutReturn Value

HKL

The return value is of type HKL. If the function succeeds, the return value is the previous input locale identifier. Otherwise, it is zero.

To get extended error information, use the GetLastError function.

ActivateKeyboardLayoutRemarks

This function only affects the layout for the current process or thread.

This function is not restricted to keyboard layouts. The hkl parameter is actually an input locale identifier. This is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input. Several input locale identifiers can be loaded at any one time, but only one is active at a time. Loading multiple input locale identifiers makes it possible to rapidly switch between them.

When multiple IMEs are allowed for each locale, passing an input locale identifier in which the high word (the device handle) is zero activates the first IME in the list belonging to the locale.

The KLF_RESET and KLF_SHIFTLOCK flags alter the method by which the Caps Lock state is turned off. By default, the Caps Lock state is turned off by hitting the Caps Lock key again. If only KLF_RESET is set, the default state is reestablished. If KLF_RESET and KLF_SHIFTLOCK are set, the Caps Lock state is turned off by pressing either Caps Lock key. This feature is used to conform to local keyboard behavior standards as well as for personal preferences.

 
友情链接
鄂ICP备19019357号-22