Enumwindows怎么使用及回调函数的用法?

caryang 2001-08-02 07:33:49
怎样使用Enumwindows及addressof后面的函数的编写?
希望举一个简单的例子!谢谢。
...全文
85 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
landog 2002-06-24
  • 打赏
  • 举报
回复
addressof
函数出错,怎么回事?
caryang 2001-08-03
  • 打赏
  • 举报
回复
另外,怎样返回所有窗口的个数呢?
我把Enumchildwindows的最后一个参数设置成要返回的窗口个数,但却没有返回值呢?
ltpao 2001-08-02
  • 打赏
  • 举报
回复
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'枚举窗口回调函数
Private Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
On Error Resume Next
Dim sBuffer As String * 255, sText As String
Call GetWindowText(hwnd, sBuffer, 256)
sText = StrZToStr(sBuffer)
EnumChildProc = True
End Function

Private Function StrZToStr(s As String) As String
If InStr(1, s, Chr$(0)) > 0 Then
StrZToStr = Left$(s, InStr(1, s, Chr$(0)) - 1)
Else
StrZToStr = s
End If
End Function


Call EnumChildWindows(GetDesktopWindow, AddressOf EnumChildProc, 0)

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧