Article ID: 168829
Article Last Modified on 2/12/2007
Control Name Property Value ------------------------------------------------ Command button Command1 Text box Text1 MultiLine TRUE Text box Text1 Scrollbars 2- VerticalNOTE: The MultiLine property only applies to Visual Basic.
Option Explicit
Public Const GW_CHILD = 5
Public Const GW_HWNDNEXT = 2
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _
ByVal wCmd 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 GetTopWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
(ByVal hwnd As Long, ByVal lpClassName As String, _
ByVal nMaxCount As Long) As Long
Sub AddChildWindows(ByVal hwndParent As Long, ByVal Level As Long)
Dim WT As String, CN As String, Length As Long, hwnd As Long
If Level = 0 Then
hwnd = hwndParent
Else
hwnd = GetWindow(hwndParent, GW_CHILD)
End If
Do While hwnd <> 0
WT = Space(256)
Length = GetWindowText(hwnd, WT, 255)
WT = Left$(WT, Length)
CN = Space(256)
Length = GetClassName(hwnd, CN, 255)
CN = Left$(CN, Length)
Me!Text1 = Me!Text1 & vbCrLf & String(2 * Level, ".") _
& WT & " (" & CN & ")"
AddChildWindows hwnd, Level + 1
hwnd = GetWindow(hwnd, GW_HWNDNEXT)
Loop
End Sub
Sub Command1_Click()
Dim hwnd As Long
hwnd = GetTopWindow(0)
If hwnd <> 0 Then
AddChildWindows hwnd, 0
End If
End Sub
MainWindowName (WindowClass)
..ChildWindowName (WindowClass)
....GrandchildWindowName (WindowClass)
Additional query words: kbVBp500 kbVBp600 kbdse kbDSupport kbVBp kbWinAPI
Keywords: kbhowto KB168829