Option Public
Option Declare
Declare Private Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Declare Private Function GetWindowText Lib "user32" Alias "GetWindowTextA"(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Private Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Private Function GetActiveWindow Lib "user32" () As Long
Declare Private Function FindWindowA Lib "user32" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Declare Private Function ShowWindow Lib "user32" Alias "ShowWindow"(ByVal lhwnd As Long, ByVal nCmdShow As Long) As Long
Declare Private Function GetClassName Lib "user32" Alias "GetClassNameA"(ByVal hwnd As long, ByVal lpClassName As string, ByVal nMaxCount As Long) As Long
Sub Initialize
Call ShowReportWindow
End Sub
Sub ShowReportWindow
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Dim CurrWnd As Long
Dim Length As Integer
Dim ListItem As String
Dim WinClass As String
'Получаем hWnd, который будет первым в списке
'через него, мы сможем отыскать другие задачи
CurrWnd = GetWindow(GetActiveWindow(), GW_HWNDFIRST)
'Пока возвращаемый hWnd имеет смысл, выполняем цикл
Do While CurrWnd <> 0
'Получаем длину имени задания по CurrW nd
Length = GetWindowTextLength(CurrWnd)
'Получить имя задачи из списка
ListItem = Space(Length + 1)
Length = GetWindowText(CurrWnd, ListItem, Length + 1)
'Если получили имя задачи, значит добавляем ее в список найденных
If Length > 0 And ListItem Like "Перечень неисполненных поручений на контроле*" Then
WinClass = Space(100)
Call GetClassName(FindWindowA(0 ,ListItem), WinClass, 100)
Call ShowWindow(FindWindowA(WinClass,0), 3)
End If
'Переходим к следующей задаче из списка
CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
DoEvents
Loop
End Sub