CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: EnumWindows API

  1. #1
    Join Date
    Oct 2006
    Posts
    18

    EnumWindows API

    Hi all,

    I am trying to find the names of all the opened Windows.
    I am using EnumWindows API, and I am at the point that I can print bunch of Window titles; however, it's printing much more than I wanted.

    For example, I have winamp, visual stuido, 1 internet explore open. The program printed out the 3 things above, but it's also printing things like:

    &File
    &File
    &File
    &File
    &File
    AutoHide
    AutoCompleteProxy
    ccApp
    etc
    .
    .
    .

    Am I using a wrong function for what I want to do?
    Thanks,
    opiston

  2. #2
    Join Date
    Nov 2006
    Location
    ntdll.dll
    Posts
    29

    Re: EnumWindows API

    Could you post some code please it could help.

    The first thing that jumps into my head is to run a check on the following in your callback function.

    Code:
    if (!IsWindowVisible(hWnd))
    		return TRUE;
    Tom

  3. #3
    Join Date
    Oct 2006
    Posts
    18

    Re: EnumWindows API

    Hi zeRoau,

    I put your code into the callback function and it's working as it should now.
    Thank you for your help.

    opiston

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,451

    Re: EnumWindows API

    Quote Originally Posted by opiston
    ...it's working as it should now...
    Just a quick note - it DID work as it should in the first place, only you didn't know that EnumWindows enumerates hidden windows too...
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

  5. #5
    Join Date
    Oct 2006
    Posts
    18

    Re: EnumWindows API

    Hey VladimirF,

    How's going?

    Quote Originally Posted by VladimirF
    Just a quick note - it DID work as it should in the first place, only you didn't know that EnumWindows enumerates hidden windows too...
    Yeah, I thought EnumWindows only enumerate the visible windows. I guess I should have said, "It's working as I want it to" =))
    Here is the definition of EnumWindows from MSDN:

    The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.
    I guess I mis-understood top-level windows.
    So what is top-level windows then?

    Thank you,
    opiston

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,451

    Re: EnumWindows API

    Quote Originally Posted by opiston
    So what is top-level windows then?
    Windows that have the Desktop Window as a parent
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

Bookmarks

Posting Permissions

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



HTML5 Development Center

Click Here to Expand Forum to Full Width