Searching Windows For Windows

This is a discussion on Searching Windows For Windows within the Windows Programming forums, part of the Platform Specific Boards category; Hi, so basically I've got a process. In that process there is a list of running windows. I want to ...

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230

    Searching Windows For Windows

    Hi, so basically I've got a process. In that process there is a list of running windows. I want to search ALL of the windows in that process for a certain child window. The problem is I'm not quite sure how to go at this. I'm trying to do a EnumWindows() and a EnumChildWindows() in its PROC. The reason I'm doing this is because I don't know the name of the window, or what text the window will have (if any). Once I find this certain child window I would like to somehow obtain the name of its parent window. Here is what I'm trying/have so far:

    Code:
    BOOL foundWindows = FALSE;
    HWND hMessageWindowATL = 0;
    
    BOOL CALLBACK EnumChildWindows(HWND hwnd, LPARAM lParam) {
    	
    	hMessageWindowATL = FindWindowEx(hwnd, NULL, "InputWindow", NULL);
    
    	if (hMessageWindowATL) {
    		foundWindows = TRUE;
    		return FALSE; // stop the enumeration
    	}
    
    	return TRUE;
    // ^ continue enumerating if InputWindow could not be found as a child window of EnumParents enumerated window (hwnd)
    }
    
    BOOL CALLBACK EnumParents(HWND hwnd, LPARAM lParam) {
    
    	EnumChildWindows(hwnd, &EnumChildWindows, NULL);
    
    	if (hMessageWindowATL)
    		return TRUE;
    
    	return FALSE;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    
    if (!foundWindows)
    			EnumWindows(&EnumParents, NULL);
    
    if (!hMessageWindowATL)
    			return 0;
    
    else
    // do stuff because the target window was found
    }
    This was an example I just cooked up, the original code is too long and confusing lol. If you need anything else let me know. Thanks.
    Last edited by pobri19; 02-07-2009 at 03:31 AM.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 09:41 PM
  2. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 11:14 AM
  3. Windows Rant followed by installation question
    By confuted in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 06-21-2003, 04:42 PM
  4. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21