enumwindow函数为什么无法遍历窗口

menuvb 2003-04-10 09:46:14
EnumWindows AddressOf EnumProc, 0 '遍查窗口

为什么我只能查找出一个,放在TIME事件也不行,!
...全文
141 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶帆 2003-04-10
  • 打赏
  • 举报
回复

Public Function GetZiWin(window_hwnd As Long) As String
Dim buflen As Long
Dim child_hwnd As Long
Dim children() As Long
Dim num_children As Integer
Dim i As Integer

'取得类名
buflen = 256
buf = Space$(buflen - 1)
buflen = GetClassName(window_hwnd, buf, buflen)
buf = Left$(buf, buflen)

If Right(buf, 4) = "Edit" Then
'----------
hWindow = window_hwnd
'----------
Exit Function
Else
hWindow = 0
End If


num_children = 0
child_hwnd = GetWindow(window_hwnd, GW_CHILD) '取得第 1 个子窗口的句柄
Do While child_hwnd <> 0 '如果有子窗口
num_children = num_children + 1
ReDim Preserve children(1 To num_children)
children(num_children) = child_hwnd

child_hwnd = GetWindow(child_hwnd, GW_HWNDNEXT) '取得下一个兄弟窗口的句柄
Loop

For i = 1 To num_children
Call GetZiWin(children(i))
Next i
End Function


Public Function EnumProc(ByVal app_hwnd As Long, ByVal lParam As Long) As Boolean '遍查主窗口

Dim buf As String * 1024
Dim length As Long
Dim Title As String

length = GetWindowText(app_hwnd, buf, Len(buf))
Title = Left$(buf, length)

If InStr(Title, "发送消息") Then '判断是否为
Call GetZiWin(app_hwnd)
End If

EnumProc = 1

End Function

wumy_ld 2003-04-10
  • 打赏
  • 举报
回复
up
佛的光辉 2003-04-10
  • 打赏
  • 举报
回复
EnumProc代码怎么写的

7,763

社区成员

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

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