VB中Enumchildwindow函数怎么用?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VB中Enumchildwindow函数怎么用?相关的知识,希望对你有一定的参考价值。

这个函数怎么用,详细点

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 module
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
参考技术A 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
);

vb怎么定义一个函数,比如用findwindow,用不了啊,出现子程序或函数未定义

'在窗体模块中定义使用下面的代码:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'在标准模块中定义使用下面的代码:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'调用示例:hWnd = FindWindow(vbNullString, "未命名 - 画图") '通过窗口标题找符合条件的窗口:成功返回窗口句柄;失败返回0,会设置GetLastError
参考技术A 你是指的api函数吧,需要在模块中定义,具体的定义语句,可以找 vb 自带的一个小工具 API浏览器追问

外接程序没有api浏览器啊

追答

你在安装目录搜索一下 apiload.exe,这个是需要自己添加的,才会在外接程序中有。实在找不到,请看这里http://jingyan.baidu.com/article/574c521917c7806c8d9dc198.html

以上是关于VB中Enumchildwindow函数怎么用?的主要内容,如果未能解决你的问题,请参考以下文章

VB怎么用API函数·详细的?

VB中randomize怎么用

请问:VB 里面的MessageBox要怎么用,整个函数是啥样的?

如何用Get和Put函数(VB)

请问vb中的move函数的使用方法有哪些?

谁能告诉我VB中SystemParametersInfo什么意思,怎么用?