VB声明
Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long)
说明
枚举窗口列表中的所有父窗口(顶级和被所有窗口)
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
lpEnumFunc Long,指向为每个子窗口都调用的一个函数的指针。用AddressOf运算符获得函数在标准模式下的地址
lParam Long,在枚举期间,传递给dwcbkd32.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的
EnumThreadWindows
VB声明
Declare Function EnumThreadWindows Lib "user32" Alias "EnumThreadWindows" (ByVal dwThreadId As Long, ByVal lpfn As Long, ByVal lParam As Long) As Long
说明
枚举与指定任务相关的窗口
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
dwThreadId Long,某线程的标识符,它的窗口将被枚举
lpfn Long,指向一个函数的指针,要求为每个子窗口都调用这个函数。用AddressOf运算符获得函数在标准模式下的地址
lParam Long,在枚举期间,传递给dwcbkd32d.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的
注解
子窗口下属的其他子窗口也可由这个函数枚举
EnumChildWindows
VB声明
Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
说明
为指定的父窗口枚举子窗口
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
hWndParent Long,欲枚举子窗口的父窗口的句柄
lpEnumFunc Long,为每个子窗口调用的函数的指针。用AddressOf运算符获得函数在一个标准模块中的地址
lParam Long,在枚举期间,传递给dwcbkd32.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的。(原文:Value that is passed to the EnumWindows event of the dwcbkd32.ocx custom control during enumeration. The meaning of this value is defined by the programmer.)
注解
在vb4下要求dwcbkd32.ocx定制控件。子窗口下属的子窗口也可由这个函数枚举
FindWindow
VB声明
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
说明
寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的标题)
返回值
Long,找到窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError
参数表
参数 类型及说明
lpClassName String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类
lpWindowName String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收任何窗口标题
注解
很少要求同时按类与窗口名搜索。为向自己不准备参数传递一个零,最简便的办法是传递vbNullString常数
示例
Dim hw&, cnt&
Dim rttitle As String * 256
hw& = FindWindow("ThunderRT5Main", vbNullString) ' ThunderRTMain under VB4
cnt = GetWindowText(hw&, rttitle, 255)
MsgBox Left$(rttitle, cnt), 0, "RTMain title"