
getting all open MDI child windows from CMainFrame
Quote:
> I generated an MDI application using appwizard and then removed all the
> document/view stuff and use my own CMDIChildWnd derived classes as the MDI
> childs. Now, I would like to get a list of all MDI childs from the MDI
> frame class (CMainFrame). Could someone tell me how this can be achieved?
Try ::EnumChildWindows on the mdi client. Here's some code:
// example callback procedure for EnumChildWindows
BOOL CALLBACK MyEnumChildProc(HWND hwndChild, LPARAM lParam)
{
// hwndChild contains the handle of the window that is
// being enumerated.
CMyMDIChildWnd* pWnd =
(CMyMDIChildWnd*)CWnd::FromHandle(hwndChild);
CString sText;
pWnd->GetWindowText(sText);
// do stuff with the text
return TRUE;
Quote:
}
// example call to enum
// this one enums the MDI Child frames in your app
::EnumChildWindows(((CMDIFrameWnd*)AfxGetMainWnd()->m_hWndMDIClient,
MyEnumChildProc, 0L);
NOTE: The MDI client member in CMDIFrameWnd is named m_hWndMDIClient, not
m_wndMDIClient.
Jim [VC/MFC MVP]
To send mail, change nospam to msn