Private Sub Form_Load()
Dim app_hwnd As Long
Dim app_parent As Long
Dim app_owner As Long
Dim app_visible As Boolean
Dim app_style As Long
Dim app_text As String
Dim app_class As String
Dim wid As Single
Dim col_wid() As Single
Dim r As Integer
Dim c As Integer
MSFlexGrid1.FixedRows = 1
MSFlexGrid1.FixedCols = 0
MSFlexGrid1.Rows = 1
MSFlexGrid1.Cols = 3
MSFlexGrid1.TextMatrix(0, 0) = "hWnd"
MSFlexGrid1.TextMatrix(0, 1) = "Text"
MSFlexGrid1.TextMatrix(0, 2) = "Class"
GetWindowInfo app_hwnd, app_parent, app_owner, _
app_visible, app_style, app_text, app_class
app_hwnd = GetTopWindow(0)
r = 1
Do While app_hwnd <> 0
' Get information about this window.
GetWindowInfo app_hwnd, app_parent, app_owner, _
app_visible, app_style, app_text, app_class
' See if this window is interesting.
If app_visible And _
app_parent = 0 And _
app_owner = 0 And _
Len(app_text) > 0 And _
Left$(app_text, 8) <> "VBBubble" And _
(Left$(app_class, 7) <> "Progman" Or _
(app_style And WS_OVERLAPPEDWINDOW) <> 0) _
Then
MSFlexGrid1.Rows = r + 1
MSFlexGrid1.TextMatrix(r, 0) = app_hwnd
MSFlexGrid1.TextMatrix(r, 1) = app_text
MSFlexGrid1.TextMatrix(r, 2) = app_class
r = r + 1
End If
app_hwnd = GetNextWindow(app_hwnd, GW_HWNDNEXT)
Loop
' Size the columns.
ReDim col_wid(0 To MSFlexGrid1.Cols - 1)
For r = 0 To MSFlexGrid1.Rows - 1
For c = 0 To MSFlexGrid1.Cols - 1
wid = TextWidth(MSFlexGrid1.TextMatrix(r, c)) + _
240
If col_wid(c) < wid Then col_wid(c) = wid
Next c
Next r
For c = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.ColWidth(c) = col_wid(c)
Next c
End Sub
' Return information about this window.
Private Sub GetWindowInfo(ByVal app_hwnd As Long, ByRef _
app_parent As Long, ByRef app_owner As Long, ByRef _
app_visible As Boolean, ByRef app_style As Long, ByRef _
app_text As String, ByRef app_class As String)
Const MAX_LENGTH = 1024
Dim buf As String * MAX_LENGTH
Dim length As Long
app_parent = GetParent(app_hwnd)
app_owner = GetWindowLong(app_hwnd, GWL_HWNDPARENT)
app_visible = IsWindowVisible(app_hwnd)
app_style = GetWindowLong(app_hwnd, GWL_STYLE)
length = GetWindowText(app_hwnd, buf, MAX_LENGTH)
app_text = Left$(buf, length)
length = GetClassName(app_hwnd, buf, MAX_LENGTH)
app_class = Left$(buf, length)
End Sub
|