VB中Enumchildwindow函数怎么用?
发布网友
发布时间:2022-09-25 20:54
我来回答
共2个回答
热心网友
时间:2023-09-21 09:26
Private Declare Function EnumChildWindows Lib "user32" (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事件的值。这个值的含义是由程序员规定的。
示例
'Example Name:EnumChildWindows
'in a form
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Me.AutoRedraw = True
EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
End Sub
'in a mole
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
'Get the windowtext length
sSave = Space$(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText hwnd, sSave, Len(sSave)
'remove the last Chr$(0)
sSave = Left$(sSave, Len(sSave) - 1)
If sSave <> "" Then Form1.Print sSave
'continue enumeration
EnumChildProc = 1
End Function
热心网友
时间:2023-09-21 09:26
Private
Declare
Function
EnumChildWindows
Lib
"user32"
Alias
"EnumChildWindows"
(ByVal
hWndParent
As
Long,
ByVal
lpEnumFunc
As
Long,
ByVal
lParam
As
Long)
As
Long
这是一个枚举子窗口的API函数,函数的第一个参数是父窗体的句柄,第二个参数是回调函数的指针,第三个参数是参数。
返回值不用
EnumChildWindows
Function
The
EnumChildWindows
function
enumerates
the
child
windows
that
belong
to
the
specified
parent
window
by
passing
the
handle
to
each
child
window,
in
turn,
to
an
application-defined
callback
function.
EnumChildWindows
continues
until
the
last
child
window
is
enumerated
or
the
callback
function
returns
FALSE.SyntaxBOOL
EnumChildWindows(
HWND
hWndParent,
WNDENUMPROC
lpEnumFunc,
LPARAM
lParam
);
热心网友
时间:2023-09-21 09:26
Private Declare Function EnumChildWindows Lib "user32" (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事件的值。这个值的含义是由程序员规定的。
示例
'Example Name:EnumChildWindows
'in a form
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Me.AutoRedraw = True
EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
End Sub
'in a mole
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
'Get the windowtext length
sSave = Space$(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText hwnd, sSave, Len(sSave)
'remove the last Chr$(0)
sSave = Left$(sSave, Len(sSave) - 1)
If sSave <> "" Then Form1.Print sSave
'continue enumeration
EnumChildProc = 1
End Function
热心网友
时间:2023-09-21 09:26
Private
Declare
Function
EnumChildWindows
Lib
"user32"
Alias
"EnumChildWindows"
(ByVal
hWndParent
As
Long,
ByVal
lpEnumFunc
As
Long,
ByVal
lParam
As
Long)
As
Long
这是一个枚举子窗口的API函数,函数的第一个参数是父窗体的句柄,第二个参数是回调函数的指针,第三个参数是参数。
返回值不用
EnumChildWindows
Function
The
EnumChildWindows
function
enumerates
the
child
windows
that
belong
to
the
specified
parent
window
by
passing
the
handle
to
each
child
window,
in
turn,
to
an
application-defined
callback
function.
EnumChildWindows
continues
until
the
last
child
window
is
enumerated
or
the
callback
function
returns
FALSE.SyntaxBOOL
EnumChildWindows(
HWND
hWndParent,
WNDENUMPROC
lpEnumFunc,
LPARAM
lParam
);