Results 1 to 4 of 4

Thread: EnumWIndows to show taskbar windows

  1. #1
    FiXeR
    Guest

    EnumWIndows to show taskbar windows

    We can always enumerate all windows with 'EnumWindows'.
    But how can we filter it to show the windows that taskbar shows

  2. #2
    Member
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    36
    I recently got this working myself, its more complex than I thought it would be...

    In a module :
    VB Code:
    1. Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
    2. Dim lReturn     As Long
    3. Dim lExStyle    As Long
    4. Dim bNoOwner    As Boolean
    5. Dim sWindowText As String
    6. Dim sWin As String
    7. '
    8. ' This callback function is called by Windows (from
    9. ' the EnumWindows API call) for EVERY window that exists.
    10. ' It populates the combobox with a list of windows that we
    11. ' are interested in.
    12. '
    13. ' Windows to display are those that:
    14. '   -   are not this app's
    15. '   -   are visible
    16. '   -   do not have a parent
    17. '   -   have no owner and are not Tool windows OR
    18. '       have an owner and are App windows
    19. '
    20. sWin = Space$(256)
    21. sWin = GetClassName(hwnd, sWin, Len(sWin))
    22. If IsWindowVisible(hwnd) Then
    23.     If GetParent(hwnd) = 0 Then
    24.         bNoOwner = (GetWindow(hwnd, GW_OWNER) = 0)
    25.         lExStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
    26.            
    27.         If (((lExStyle And WS_EX_TOOLWINDOW) = 0) And bNoOwner) Or _
    28.             ((lExStyle And WS_EX_APPWINDOW) And Not bNoOwner) Then
    29.             '
    30.             ' Get the window's caption.
    31.             '
    32.             sWindowText = Space$(256)
    33.             lReturn = GetWindowText(hwnd, sWindowText, Len(sWindowText))
    34.             If lReturn Then
    35.                 '
    36.                 ' Add it to our list.
    37.                 '
    38.                 WindCount = WindCount + 1
    39.                 sWindowText = Left$(sWindowText, lReturn)
    40.                 frmFindWindow.cboWindows.AddItem sWindowText
    41.             End If
    42.         End If
    43.     End If
    44. End If
    45. EnumWindowsProc = True
    46. End Function

    In your form :
    VB Code:
    1. Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
    2.  
    3. Call EnumWindows(AddressOf EnumWindowsProc, frmFindWindow.cboWindows.hwnd)

  3. #3
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    Could you please include your declares and constants. It is a little bit tedious to go through your code to find what needs to be declared and what does not. Thank you.

    Joe

  4. #4
    Member
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    36
    You mean these ones ?

    VB Code:
    1. Public Const WS_EX_TOOLWINDOW = &H80
    2. Public Const WS_EX_APPWINDOW = &H40000
    3. Public Const GW_OWNER = 4
    4. Public Const GWL_EXSTYLE = (-20)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width