Hi
Use the function EnumChildWindows. This function uses a callback. I already explained this a few threads ago concerning an other function that uses callback.
I test the following code in a dialog bow where I put a button called IDC_GET and several other controls. The OnGet() is the handler of this button.
Here it is:
void CEnumChildDlg::OnGet()
{
HWND hwnd = this->GetSafeHwnd();
if ( !EnumChildWindows( hwnd, EnumChildProc, ( LPARAM) hwnd))
AfxMessageBox( "Problem getting Child Windows"

;
}
The first parameter is the handle of the parent window. The third parameter is the parameter that is passed to the callback function. In this case, this is the same handle. It could be used to transfer data back to the calling process. Remember that a static function accesses only static members, so passing the handle of the calling process is a mean to exchange data between a static and a non-static member. See the code below
Remember thet a callback must be declared static.
As this:
public:
static BOOL CALLBACK EnumChildProc( HWND hwnd, LPARAM lParam);
In this simple example, I'll just display the control id in the debug window ...
BOOL CALLBACK CEnumChildDlg::EnumChildProc( HWND hwnd, LPARAM lParam)
{
// Get a Pointer to the window found by EnumChildWindows function (first param)
CWnd* pWnd = CWnd::FromHandle( hwnd);
CString str;
if ( pWnd != ( CWnd*) NULL) // Safety Check
{
str.Format( "Child Id %d \n", pWnd->GetDlgCtrlID());
::OutputDebugString( str);
return TRUE;
}
return FALSE;
}
If you want to update a member in the calling class, you can do it like this:
I'll assume here that the calling class is CEnumChildDlg.
CEnumChildDlg* pParentWnd =
( CEnumChildDlg* ) CWnd::FromHandle( ( HWND) lParam);
// Update Member of CEnumChildDlg class
pParentWnd-> .... = pWnd->GetDlgCtrlID();
In this case you update a memmber of the class CEnumChildDlg from within the callback function. Of course, if you need to transfer the id of all child windows, you'll use an array or a list...
HTH
Thierry
EMail: Thierry.Marneffe@swing.be