CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    1,361

    [RESOLVED] FindWindowEX question

    I am looking to find a particular dialog box. I used the Spy tool and it gave me the class name for this dialog box as "#32770 (Dialog)". If I use FindWindowEx(NULL, NULL,"#32770 (Dialog)", NULL), I always get a null in return, however, FindWindowEx(NULL, NULL,NULL, NULL) actually lets me iterate through the windows and find the window I am looking for.

    I just want to make sure I do not find a similarly named window (unlikely, but possible). Anyway here is a more complete code fragment of my search:
    Code:
    void WLanConfig::SupGUIWatch()
    {
    	vector<char> Buffer;
    	Buffer.resize( 1025, 0 );
    
    	while ( ( false == FoundSupGUI ) && ( false == AbortWait ) && ( false == KillSupGUIWatch ) )
    	{
    		HWND h1 = NULL, h2 = NULL;
    
    		// This finds the window I am looking for although I need to iterate through a lot of windows.
    		h1 = FindWindowEx(NULL, h2,NULL, NULL);
    
    		// This does not, the class name was gotten by using DevStudio's spy tool
    		// h1 = FindWindowEx(NULL, h2,"#32770 (Dialog)", NULL); // Always returns NULL
    		while ( h1 != NULL )
    		{
    			int Len = (int)SendMessage(h1, WM_GETTEXT, 1024, (LPARAM)&Buffer[0]);
    
    			if ( Len > 2 )
    			{
    				CString MatchBuff;
    				MatchBuff = &Buffer[0];
    				if ( -1 != MatchBuff.Find( "Windows Security" ) )
    				{
    					Logger::Log.Format("Found the supplicant GUI \"%s\"", &Buffer[0] );
    					LOGQ( 1 );
    
    					GetWindowRect( h1, &SupGUIWindowRect );
    
    					FoundSupGUI = true;
    					break;
    				}
    			}
    
    			h2 = h1;
    			h1 = FindWindowEx(NULL, h2, NULL, NULL);
    			// h1 = FindWindowEx(NULL, h2, "#32770 (Dialog)", NULL);
    		} // while ( h1 != NULL )
    
    		Sleep(50);
    	} // while ( ( false == FoundBubble) && ( false == AbortWait ) )
    
    
    }
    I want to know why specifying the class name fails in this case. I does look like a strange name, and I am guessing Spy isn't telling me the accurate name. If this is the case, how can I find the accurate name of a window's class?

  2. #2
    Join Date
    Sep 2004
    Posts
    1,361

    Re: FindWindowEX question

    Never mind, found the problem. The actual class name is "#32770" and the " (CDialog)" was something spy added.

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