EnumChildWindows() follows the typical C callback idiom. You can pass the third parameter a pointer to anything you want and EnumChildWindows() will forward that data to the callback without caring what it is. For example, you could pass a pointer to an object:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
struct data{
int handle_id;
HWND result;
};
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam){
auto &d = *(data *)lParam;
int id = GetDlgCtrlID(hwnd);
if (id == d.handle_id){
cout << "id = " << id << endl;
cout << "hwnd_Child = " << hwnd << endl;
d.result = hwnd;
returnfalse;
}
returntrue;
}
data d = {5680, nullptr};
EnumChildWindows(HWND(0x9563215), EnumChildProc, (LPARAM)&d);