Sorry for the confusing title! , Ok I have a window that has about 20 windows that come from that, of that 20 only one of them has child windows , 3 of them (and that's the one I actually want).
Spy++ has no captions for any of these windows and the handles of the children change everytime the main window is opened. So I am looking for a way to say "Enumerate all children of this window that has children itself and then store that handle". Is this possible :) ?
In your case you would want an EnumWindowsProc that counts the number of children windows. And then another EnumWindowsProc that calls the counting proc for all 20 of the windows you mentioned in your post.
Let me know if this helps :)
Ok It seems to be just returning the caption of a specified window rather than the windows/controls attached to each? Is there an easy way to loop through all windows or controls attached to each window? and display them line by line and from that I guess I would try to find which one of those hand child windows/controls attached to it?
So instead of the SendMessage(hwnd, WM_GETTEXT, sizeof(buffer), (LPARAM)(void*)buffer); GETTEXT grabbing the text of the window I specifiy I wonder if I can get it to list all controls off of it?
EnumWindowsProc function pointers are meant to be passed to EnumWindows. You seem to be calling one by itself in your main function. What you want to do instead is call EnumWindows and pass a function pointer to an EnumWindowsProc function. This might seem a little confusing, but EnumWindowsProc is actually a function type. Kind of like int is a type of data variable. EnumWindows is a function in the Windows API that can accept a pointer to a function that has the EnumWindowsProc type.
EnumWindowsProcA could count the number of child windows
EnumWindowsProcB could return success if it finds a window with 3 children
Then in main call EnumWindows with the hwnd to the window that holds 20 windows and the EnumWindowsProcB pointer.
In EnumWindowsProcB call EnumWindows with the EnumWindowsProcA pointer and if you get 3 return a success to main somehow.
So basically:
Loop through all the child windows by calling another EnumWindows instead of calling cout to display the window's title.