CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2000
    Posts
    21

    EnumWindows enumerates too much windows !

    Hi everybody,

    A new problem for me : I would like to enumerate the current running windows in my computer. I use the EnumWindows function to do it. EnumWindows does enumerate too much windows for me and I would like it to give me only the opened and visible windows.

    If you run the Spy++ program, you'll get all the windows (the visible and the hidden one) in it. It's too much in my case. I just want the one which appears in the task bar.

    Thanks a lot...


  2. #2
    Join Date
    May 2000
    Location
    Toronto, ON, Canada
    Posts
    3,573

    Re: EnumWindows enumerates too much windows !

    Hi,

    Use thisvoid EnumApp()
    {
    HWND hWnd, hWndNext;
    char szWindowName[1024];

    hWnd = ::GetDesktopWindow();
    if (hWnd != NULL)
    {
    hWndNext = ::GetTopWindow(hWnd);
    while (hWndNext != NULL)
    {
    ::GetWindowText(hWndNext, szWindowName, sizeof(szWindowName));
    if ((strlen(szWindowName) > 0) && (::IsWindowVisible(hWndNext)))
    TRACE("visible windows %s\n", szWindowName);
    hWndNext = ::GetNextWindow(hWndNext, GW_HWNDNEXT);
    }
    }
    }

    Tell me if that help.

    Regards,
    Emi.
    Regards,

    Emanuel Vaduva

  3. #3
    Join Date
    Oct 1999
    Location
    Broomfield, CO
    Posts
    3,382

    Re: EnumWindows enumerates too much windows !

    You could use the window handle returned from EnumWindows to call GetWindowInfo. Check the window style against what you are looking for, and ignore any window that doesn't meet your criteria.


  4. #4
    Join Date
    Mar 2000
    Posts
    21

    Re: EnumWindows enumerates too much windows !

    OK, thanks for your help.

    Here is the solution I've kept to resolve my problem :

    CWnd* pParentWindow = GetParent();
    CWnd* pNextWindow = pParentWindow->GetWindow(GW_HWNDNEXT);
    while(pNextWindow)
    {
    if((!pNextWindow->IsIconic()) && (pNextWindow->IsWindowVisible())
    // OK, the window can overlap my draw area, I have to do GetWindowRect to control the
    // coords of both draw area and window found

    pNextWindow = pNextWindow->GetWindow(GW_HWNDNEXT);
    }

    In parallel to that solution, I've found another way to be sure that no window overlaps my draw area.
    I just test if the active window is the draw area parent window. If it's not the case, I know that my
    draw area can be overlapped. If it's the case, may be my draw area is completely visible and not
    overlapped.

    However, I have to verify that my own parent window doesn't overlap my draw area.

    OK, thanks a lot again for your precious help...


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

Featured