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

Thread: Get all open window

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    21

    Get all open window

    How to get list of open application (i don't think proces).

  2. #2
    Join Date
    Apr 2008
    Posts
    133

    Re: Get all open window

    If you want to get all open windows ..use EnumWindows.
    It will return you the handle to all top level windows

  3. #3
    Join Date
    Feb 2000
    Location
    Indore, India
    Posts
    1,046

    Re: Get all open window

    Hello,

    You can use FindWindow call to get windows of whatever type of relation to the specified window.

    For example, the code given below will get all the windows open on desktop.

    Code:
    // Get the topmost window in Z order
    HWND hWnd = GetWindow(hwnd, GW_HWNDFIRST);
    while (hWnd != NULL)		// If the window handle is valid
    {
    	if (IsWindowVisible(hWnd))	// If the window is visible
    	{
    		// Get window details and process info
    		...
    	}
    	// Loops through all windows
    	hWnd = GetWindow(hWnd, GW_HWNDNEXT);
    }
    Regards,
    Pravin.
    Let me know if I have helped by rating this post

    Recent FAQs

    Drag an image
    Area of a window exposed on desktop
    Display rotated bitmap

  4. #4
    Join Date
    Jan 2008
    Posts
    178

    Re: Get all open window

    Quote Originally Posted by Pravin Kumar
    For example, the code given below will get all the windows open on desktop.
    Bad code.
    Always use EnumWindows()

  5. #5
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,917

    Re: Get all open window

    Quote Originally Posted by fred100
    Bad code.
    What is "bad" about this code?

    Quote Originally Posted by fred100
    Always use EnumWindows()
    Why?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

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

    Re: Get all open window

    Quote Originally Posted by JohnCz
    What is "bad" about this code?

    Why?
    I could only guess what fred100 had in mind. And my guess is - this comment from MSDN:

    EnumWindows Function

    Remarks

    ...This function is more reliable than calling the GetWindow function in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)