ActivateKeyboardLayout

ActivateKeyboardLayout【ActivateKeyboardLayout】ActivateKeyboardLayout是一个为激活键盘布局提供服务的计算机函式 。
基本介绍中文名:ActivateKeyboardLayout
函式功能:激活键盘布局
函式原型:HKL ActivateKeyboardLayout
hkl:将被激活的键盘布局的句柄
函式功能激活键盘布局 。该函式Windows NT和Windows 95中的实现有很大不同 。本参考页中首先给出了完整的Windows NT的实现,下来又给出了Windows 95版本的实现,以便大家更好地了解二者的区别 。在Windows NT中ActivateKeyboadLayout函式激活一种不同的键盘布局,同时在整个系统中而不仅仅是调用该函式的进程中将该键盘布局设为活动的 。函式原型HKL ActivateKeyboardLayout( HKL hkl,UINT Flags);参数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 函式替代 。返回值如果函式调用成功,返回值为前一键盘布局的句柄 。否则,返回值为零 。若要获得更多多错误信息,可调用GetLastError函式 。备注:在任一时刻可以装入多种键盘布局,但一次仅能激活一种布局 。装入多种键盘布局使得可以快速地在多种布局之间切换 。Windows 95 ACtivateKeyboadLayout函式为当前执行绪设定输入语言 。该函式接受一个键盘布局句柄,该句柄标识键盘的一个局部的和物理布局 。速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:不支持;头档案:winuser.h;库档案:user32.lib 。[English Version By MSDN]Parametershkl [in] 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 [in] 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.Return ValueHKLThe 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.RemarksThis function only affects the layout for the current process or thread.This function is not restricted to keyboard layouts. The