Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleCascade Internet Explorer windows on the desktop
Keywordscascade, internet explorer, arrange windows, desktop
CategoriesAPI, Software Engineering
 
Use the EnumWindows API function to enumerate the system's windows.
 
Private Sub cmdCascadeIE_Click()
    EnumWindows AddressOf WindowEnumerator, 0
End Sub
 
EnumWindows calls an enumeration function for each window. That function determines whether the window's title contains the strings " - Microsoft Internet Explorer" or " - Outlook Express". If it does, the code uses the SetWindowPos API function to position the window.
 
' 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
 
This example arranges the windows so each is shifted a bit down and to the left of the previous one. You could modify it to arrange windows in other ways.
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated