int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1;
if (m_wndMDIClient.Attach(m_hWndMDIClient) == 0) { TRACE0("Failed to attach MDIClient.\n"); return -1; // fail to create } //................. }
//---------------------------------------------------------------- // This function finds the CMDIChildWnd in the list of windows // maintained by the application's MDIClient window following the // one pointed to by the member variable m_pWndCurrentChild. If no // further CMDIChildWnds are in the list, NULL is returned. //----------------------------------------------------------------
CMDIChildWnd* CMainFrame::GetNextMDIChildWnd() { if (!m_pWndCurrentChild) { // Get the first child window. m_pWndCurrentChild = m_wndMDIClient.GetWindow(GW_CHILD); } else { // Get the next child window in the list. m_pWndCurrentChild= (CMDIChildWnd*)m_pWndCurrentChild->GetWindow(GW_HWNDNEXT); }
if (!m_pWndCurrentChild) { // No child windows exist in the MDIClient, // or you are at the end of the list. This check // will terminate any recursion. return NULL; }
// Check the kind of window if (!m_pWndCurrentChild->GetWindow(GW_OWNER))