API函数
- 格式:doc
- 大小:585.50 KB
- 文档页数:72
1.控件与消息函数
AdjustWindowRect,AdjustWindowRectEx
VB声明
Declare Function AdjustWindowRect Lib "user32" Alias "AdjustWindowRect" (lpRect As RECT, ByVal
dwStyle As Long, ByVal bMenu As Long) As Long
Declare Function AdjustWindowRectEx Lib "user32" Alias "AdjustWindowRectEx" (lpRect As RECT, ByVal
dsStyle As Long, ByVal bMenu As Long, ByVal dwEsStyle As Long) As Long
说明
在给定一种窗口样式的前提下,计算获得目标客户区矩形所需的窗口大小
返回值
Long,如执行成功,则返回非零值;如失败,返回零值。会设置GetLastError
参数表
参数 类型及说明
lpRect RECT,最初包含要求的客户区。由函数设为目标窗口矩形大小
dwStyle Long,窗口样式
bMenu Long,如窗口有菜单,则设为TRUE(非零)
dwEsStyle Long,扩展窗口样式(只适用于AdjustWindowRectEx)
注解
在调用本函数前,先用GetWindowLong取得一个窗体的样式。如菜单占用两行以上的空间,则函数不能正确计算大小。如程序使用了多行标题,则应使用GetSystemMetrics
AnyPopup
VB声明
Declare Function AnyPopup Lib "user32" Alias "AnyPopup" () As Long
说明
判断屏幕上是否存在任何弹出式窗口
返回值
Long,如存在弹出式菜单,则返回TRUE(非零) 注解
对该函数来说,弹出式菜单包含所有可见的包容顶级窗口,无论弹出式还是重叠窗口
ArrangeIconicWindows
VB声明
Declare Function ArrangeIconicWindows Lib "user32" Alias "ArrangeIconicWindows" (ByVal hwnd As Long)
As Long
说明
排列一个父窗口的最小化子窗口(在vb里使用:用于在桌面排列图标,用GetDesktopWindow函数获得桌面窗口的一个句柄)
返回值
Long,图标行的高度;如失败,则返回零。会设置GetLastError
参数表
参数 类型及说明
hwnd Long,父窗口的句柄
注解
也可将该函数用于包含了图标化子窗口的的定制控件
AttachThreadInput
VB声明
Declare Function AttachThreadInput Lib "user32" Alias "AttachThreadInput" (ByVal idAttach As Long, ByVal
idAttachTo As Long, ByVal fAttach As Long) As Long
说明
通常,系统内的每个线程都有自己的输入队列。本函数(既“连接线程输入函数”)允许线程和进程共享输入队列。连接了线程后,输入焦点、窗口激活、鼠标捕获、键盘状态以及输入队列状态都会进入共享状态
返回值
Long,非零表示成功,零表示失败,会设置会GetLastError
参数表
参数 类型及说明 idAttach Long,欲连接线程的标识符(ID)
idAttachTo Long,与idAttach线程连接的另一个线程的标识符
fAttach Long,TRUE(非零)连接,FALSE撤消连接
注解
调用这个函数时,会重设键盘状态
BeginDeferWindowPos
VB声明
Declare Function BeginDeferWindowPos Lib "user32" Alias "BeginDeferWindowPos" (ByVal nNumWindows
As Long) As Long
说明
启动构建一系列新窗口位置的过程(以便同时更新)。该函数会向一个内部结果返回一个句柄,这个结构容纳了与窗口位置有关的信息。随后,该结构会由对DeferWindowPos函数的调用填充。准备好更新所有窗口位置以后,对EndDeferWindowPos的一个调用可同时更新结构内所有窗口的位置
返回值
Long,内部结构的句柄。零表示失败
参数表
参数 类型及说明
nNumWindows Long,在结构中欲为其分配空间的初始窗口数量。在每次DeferWindowPos调用期间结构的大小会根据情况自动调节
BringWindowToTop
VB声明
Declare Function BringWindowToTop Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Long) As
Long
说明
将指定的窗口带至窗口列表顶部。倘若它部分或全部隐藏于其他窗口下面,则将隐藏的部分完全显示出来。该函数也对弹出式窗口、顶级窗口以及MDI子窗口产生作用
返回值
Long,非零表示成功,零表示失败。会设置GetLastError 参数表
参数 类型及说明
hwnd Long,欲带至顶部的那个窗口的句柄
注解
这个函数也许能随同子窗口使用。函数对一个特定的输入线程来说是“本地的”——换言之,倘若某窗口并非前台应用程序的一部分,那么一旦随同该窗口调用本函数,仍会将窗口带至它自己那个应用程序的窗口列表顶部。但是,不会同时使那个应用成为前台应用程序。这意味着在调用了本函数后,窗口仍会保持隐藏状态
CascadeWindows,CascadeWindowsBynum
VB声明
Declare Function CascadeWindows% Lib "user32" (ByVal hwndParent As Long, ByVal wHow As Long, lpRect
As RECT, ByVal cKids As Long, lpKids As Long)
Declare Function CascadeWindowsBynum% Lib "user32" Alias "CascadeWindows" (ByVal hwndParent As
Long, ByVal wHow As Long, ByVal lpRect As Long, ByVal cKids As Long, ByVal lpKids As Long)
说明
以层叠方式排列窗口(在vb里使用:位于顶部或被所有的窗口没有问题。原文:No problem for top level
windows or owned windows.)
返回值
Integer,排列成功的窗口数量,零表示失败
参数表
参数 类型及说明
hwndParent Long,指定一个父窗口;准备对它的子窗口进行排列。用GetDesktopWindow函数获得顶级窗口的句柄
wHow Long,MDITILE_SKIPDISABLED——不排列已被禁用的MDI子窗口
lpRect RECT,指定一个矩形,矩形区域中的窗口才会层叠处理。可设为NULL,表示使用整个客户区
cKids Long,在lpKids数组中指定的子窗口数量
lpKids Long,子窗口列表中准备排列的第一个元素。如传递NULL(注意将参数定义成ByVal)。Long,则表示排列所有的子窗口(原文:Long--First element in list
of child windows to arrange. Pass NULL (be sure to define parameter as ByVal - Long, to arrange all child windows.)
注解
在正式的win32文档里,对这个函数的说明是不正确的。这儿的参数建立在实际的win32 C 头文件基础上。函数不能对诸如控件的子窗口产生——只对顶级窗口及MDI子有用。注意在MDI窗体的情况下,指定的父窗口应是MDIClient窗口的句柄,不应是MDI窗体本身的窗口句柄。可用api函数GetParent获得正确的句柄
ChildWindowFromPoint,ChildWindowFromPointEx
VB声明
Declare Function ChildWindowFromPoint Lib "user32" Alias "ChildWindowFromPoint" (ByVal hWnd As
Long, ByVal xPoint As Long, ByVal yPoint As Long) As Long
Declare Function ChildWindowFromPointEx Lib "user32" Alias "ChildWindowFromPointEx" (ByVal hWnd As
Long, ByVal pt As POINTAPI, ByVal un As Long) As Long
说明
返回父窗口中包含了指定点的第一个子窗口的句柄
返回值
Long,发现包含了指定点的第一个子窗口的句柄。如未发现任何窗口,则返回hWnd(父窗口的句柄)。如指定点位于父窗口外部,则返回零
参数表
参数 类型及说明
hWnd Long,父窗口的句柄
xPoint Long,点的X坐标,以像素为单位
yPoint Long,点的Y坐标,以像素为单位
pt POINTAPI,点的坐标,以像素为单位
un Long,(只适用于ChildWindowFromPointEx)控制对窗口的搜索。参见下表
CWP_ALL 测试所有窗口
CWP_SKIPINVISIBLE 忽略不可见窗口
CWP_SKIPDISABLED 忽略已屏蔽的窗口
CWP_SKIPTRANSPARENT 忽略透明窗口