Click here to Skip to main content
16,017,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All..

Am facing a problem in identifying the child window, Let me explain this... Here child window title is "Liquidate Position : 3692". Here everytime in child window Reference ID will be different i.e.,For Eg: 1) "Liquidate Position :3693" (2)"Liquidate Position : 4521" . So, if I want to identify the child window using the FindWindow() API, it will be quite difficult because everytime window title changes. So tought of identifying the Child window by mentioning the substring using EnumWindows and my code looks like this:

C++
BOOL CALLBACK FindWindowBySubstr(HWND hwnd, LPARAM substring)
{
    const DWORD TITLE_SIZE = 1024;
    TCHAR windowTitle[TITLE_SIZE];

    if (GetWindowText(hwnd, windowTitle, TITLE_SIZE))
    {
        if (_tcsstr(windowTitle, LPCTSTR(substring)) != NULL)
        {
	  BOOL b = ::IsWindowVisible(hwnd);
	  if( b)
          {
            AfxMessageBox(windowTitle,0,0);
            //Child window identified.... Do some stuff with that....
	  }
            return false;
        }
    }
    return true; // Need to continue enumerating windows
}


C++
const TCHAR substring[] = TEXT("Liquidate");
EnumWindows(FindWindowBySubstr, (LPARAM)substring);


With this my code anyway am able to find the child window here, thats great !!! But the problem is.. while tracing the code
C++
GetWindowText(hwnd, windowTitle, TITLE_SIZE)
It finds the windows like Start,CiceroUIWndFrame,JumpList,Task Switching,Start menu,IDD_EIML_Dialog-Dialog,Network Flyout and so on.. And i think it finds all the windows on my system.

But my application is completely time constraint application eventhough 1~2sec delay will create a problem for me. And moreover this code finds all the windows on the system & obviously it will consume lot of time.
Please can anyone suggest/guide me the fastest way to find it..

Thank you all..
Posted

1 solution

If you know the parent window, use EnumChildWindows[^] instead. It has the similar syntax, and uses the same callback function
 
Share this answer
 
Comments
Guru_C++ 27-Nov-12 0:46am    
Woh !!! Great :) It worked... Thanks Andrew..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900