Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: MFC
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++ at 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
0 OriginalGriff 339
1 DineshMaind 95
2 Sergey Alexandrovich Kryukov 94
3 majid torfi 85
4 kbrandwijk 75
0 Zubair MCA 55
1 OriginalGriff 55
2 sankarsan parida 55
3 harshavardhan12345678 45
4 Sandeep Londhe 45

Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2014
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