' Return False to stop the enumeration.
Public Function WindowEnumerator(ByVal app_hwnd As Long, _
ByVal lparam As Long) As Long
Const SWP_NOACTIVATE = &H10
Const SWP_NOZORDER = &H4
Dim targets() As Variant
Dim widths() As Variant
Dim heights() As Variant
Dim buf As String * 256
Dim title As String
Dim length As Long
Dim i As Integer
targets = Array( _
" - Microsoft Internet Explorer", _
" - Outlook Express")
widths = Array(800, 800)
heights = Array(500, 550)
If m_MinY = 0 Then
m_MinY = Form1.ScaleY(Screen.Height, vbTwips, _
vbPixels) - _
100 - heights(LBound(heights)) - 5 * DX
m_MinX = 5 * DX
End If
' Get the window's title.
length = GetWindowText(app_hwnd, buf, Len(buf))
title = Left$(buf, length)
' See if the title contains the target.
For i = LBound(targets) To UBound(targets)
If InStr(title, targets(i)) > 0 Then
SetWindowPos app_hwnd, 0, _
m_MinX, m_MinY, widths(i), heights(i), _
SWP_NOACTIVATE Or SWP_NOZORDER
m_MinX = m_MinX - DX
m_MinY = m_MinY + DX
Exit For
End If
Next i
WindowEnumerator = True
End Function
|