对于有标题的子窗体,用EnumChildWindows可以全部列举出来。但对没有标题的窗体,EnumChildWindows好像不能枚举出来。用什么函数可以列出无标题的窗体的hWnd以下是我列举一个窗体下所有子窗体的代码(只能列举有标题窗体),请高手指教。---------------------------------------------------------
frm中代码:Private Sub Command1_Click()
Dim hw As Long
If Text2.Text <> "" Then
hw = FindWindow(vbNullString, Text2.Text)
List1.Clear
EnumChildWindows hw, AddressOf EnumWindowsProc, 0&
Text1.Text = hw
Else
MsgBox "未指定窗口标题"
Text2.SetFocus
End If
End Sub
--------------------------------------------------------------
Module中代码(声明部分已经去掉)Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim S As String
S = String(80, 0)
Dim cS As String
cS = String(80, 0)
Call GetWindowText(hwnd, S, 80)
Call GetClassName(hwnd, cS, 80)
S = Left(S, InStr(S, Chr(0)) - 1)
cS = Left(cS, InStr(cS, Chr(0)) - 1)
If Len(S) > 0 Then frm.List1.AddItem S & " , " & cS
EnumWindowsProc = True
End Function
frm中代码:Private Sub Command1_Click()
Dim hw As Long
If Text2.Text <> "" Then
hw = FindWindow(vbNullString, Text2.Text)
List1.Clear
EnumChildWindows hw, AddressOf EnumWindowsProc, 0&
Text1.Text = hw
Else
MsgBox "未指定窗口标题"
Text2.SetFocus
End If
End Sub
--------------------------------------------------------------
Module中代码(声明部分已经去掉)Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim S As String
S = String(80, 0)
Dim cS As String
cS = String(80, 0)
Call GetWindowText(hwnd, S, 80)
Call GetClassName(hwnd, cS, 80)
S = Left(S, InStr(S, Chr(0)) - 1)
cS = Left(cS, InStr(cS, Chr(0)) - 1)
If Len(S) > 0 Then frm.List1.AddItem S & " , " & cS
EnumWindowsProc = True
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货