CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2008
    Location
    The Netherlands
    Posts
    18

    EnumWindows filter to only windows that show up on alt-tab

    Hey People,

    I've been working on an application that needs to create a list of all open windows.

    So far I've got EnumWindows working with a callback, but I can't seem to filter all windows out that don't show up during alt-tabbing.

    How would I filter those windows out ? Below are the checks I already enforced in my callback function.

    Code:
    	if(hWnd == NULL)
    		return true;
    
    	int titleLength = GetWindowTextLength(hWnd);
    	if(0 == titleLength)
    		return true;
    
    	if( ( false == IsWindowVisible(hWnd) || false == IsIconic(hWnd) ) && false == IsWindow(hWnd))
    		return true;
    
    	if(GetParent(hWnd) != 0)
    		return true;
    
    	// Add it to the list here
    So what would I need to add to filter it to windows only seeable on alt-tab ?

    Thank you for your time, Xeross

  2. #2
    Join Date
    Sep 2009
    Posts
    1

    Re: EnumWindows filter to only windows that show up on alt-tab

    Hello, xeross,

    Did you found solution?
    I use the next code to get a list of all opened windows. And it works fine for me.

    Code:
    static BOOL CALLBACK EnumWindowsCallback(IN HWND hWnd, IN LPARAM lParam)
    {
        if (!IsWindowVisible(hWnd)) || GetWindow(hWnd, GW_OWNER) != NULL)
            return TRUE;
    
        TCHAR szText[256];
        DWORD cchText = GetWindowText(hWnd, szText, 256);
    
        if (cchText == 0)
            return TRUE;
    
       // there we have a "true" window
    
    }
    PS: one window is not wanted. "Program Manager" is a main window which contains a desktop. But this is not a serious problem, isn't it?

    Regards, Dimitry

  3. #3
    Join Date
    Oct 2008
    Location
    The Netherlands
    Posts
    18

    Re: EnumWindows filter to only windows that show up on alt-tab

    Thanks, I'll try it out.

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