Click here to Skip to main content
12,955,118 members (68,978 online)
Rate this:
Please Sign up or sign in to vote.
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:

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)
            //Child window identified.... Do some stuff with that....
            return false;
    return true; // Need to continue enumerating windows

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
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 25-Nov-12 19:52pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you know the parent window, use EnumChildWindows[^] instead. It has the similar syntax, and uses the same callback function
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,559
CHill60 3,550
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100