c++ - enumerate child windows doesn't function, but enumWindows does...? -
heading
i don't know why, when start enumerating windows, goes correctly, enumerating child windows not enter function... , moves around code... if put hwnd = 0 runs... have no idea why not hwnd find child windows.
enter code here #include "stdafx.h" #include <windows.h> #include <iostream> using namespace std; hwnd h; int wpoc, chpoc; static bool callback enumwindowsproc(hwnd hprog, long lparam) { wpoc++; cout << wpoc << ": " << hprog << endl; if(wpoc == 5) h = hprog; if (wpoc > 20) return false; return true; } static bool callback enumchildproc(hwnd hprog, long lparam) { chpoc++; cout <<"ch "<< chpoc << endl; if (chpoc > 20) return false; return true; } void search() { wpoc = 0; bool procsuccess; procsuccess = enumwindows((wndenumproc)enumwindowsproc,null); } void searchmap() { chpoc = 0; bool procsuccess; procsuccess = enumchildwindows( h,(wndenumproc)enumchildproc,null); } int _tmain(int argc, _tchar* argv[]) { search(); searchmap(); return 0; }
i made simple code find mistakes , same... don't know wrong... help.
it's not work you, because found window no childrens. debug stuff. paste breackpoint after serach()
, see value of h
. open spy++ , find handle same value h
. see if window has childrens. possible output:
1: 0004069e 2: 000305c4 3: 00030526 4: 00010158 5: 000100ba 6: 000100bc 7: 000100a6 8: 000100aa 9: 000100ac 10: 0001008e 11: 000100a2 12: 000100a4 13: 00010086 14: 00050598 15: 0006052e 16: 0010042e 17: 0011041a 18: 000d040c 19: 000803b8 20: 000903bc 21: 000903c8 ch 1 ch 2 ch 3 ch 4
Comments
Post a Comment