Public Type ProcData
AppHwnd As Long
ClassName As String
Title As String
Placement As String
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public ProcInfo() As ProcData
Public NumProcs As Integer
Public Function EnumProc(ByVal app_hwnd As Long, ByVal _
lParam As Long) As Boolean
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3
Dim wp As WINDOWPLACEMENT
Dim buf As String * 1024
Dim length As Long
NumProcs = NumProcs + 1
ReDim Preserve ProcInfo(1 To NumProcs)
With ProcInfo(NumProcs)
.AppHwnd = app_hwnd
' Get the window's class name.
length = GetClassName(app_hwnd, buf, Len(buf))
.ClassName = Left$(buf, length)
' Get the window's title.
length = GetWindowText(app_hwnd, buf, Len(buf))
.Title = Left$(buf, length) & " "
' See where the window is.
wp.length = Len(wp)
GetWindowPlacement app_hwnd, wp
Select Case wp.showCmd
Case SW_SHOWNORMAL
.Placement = "Normal"
Case SW_SHOWMINIMIZED
.Placement = "Minimized"
Case SW_SHOWMAXIMIZED
.Placement = "Maximized"
End Select
.Left = wp.rcNormalPosition.Left
.Top = wp.rcNormalPosition.Top
.Right = wp.rcNormalPosition.Right
.Bottom = wp.rcNormalPosition.Bottom
End With
' Continue searching.
EnumProc = 1
End Function
|