CMDIChildWnd* CMDIFrameWnd::CreateNewChild(CRuntimeClass* pClass, UINT nResources, HMENU hMenu /* = NULL */, HACCEL hAccel /* = NULL */) { ASSERT(pClass != NULL); CMDIChildWnd* pFrame = (CMDIChildWnd*) pClass->CreateObject(); ASSERT_KINDOF(CMDIChildWnd, pFrame); // load the frame CCreateContext context; context.m_pCurrentFrame = this; pFrame->SetHandles(hMenu, hAccel); if (!pFrame->LoadFrame(nResources, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context)) { TRACE(traceAppMsg, 0, "Couldn't load frame window.\n"); return NULL; } CString strFullString, strTitle; if (strFullString.LoadString(nResources)) AfxExtractSubString(strTitle, strFullString, CDocTemplate::docName); // redraw the frame and parent pFrame->SetTitle(strTitle); pFrame->InitialUpdateFrame(NULL, TRUE); return pFrame; }
void CFormObj::OnEdit() { POSITION pos = m_pFormDoc->GetFirstViewPosition(); if (pos != NULL) { CView* pView = m_pFormDoc->GetNextView(pos); if (pView != NULL) { CMDIChildWnd* pFrame = (CMDIChildWnd *)pView->GetParentFrame(); CMDIChildWnd* pActiveFrame = ((CMainFrame *)AfxGetMainWnd())->MDIGetActive(); if (pFrame != NULL && pFrame != pActiveFrame) ((CMainFrame *)AfxGetMainWnd())->MDIActivate(pFrame); return; } } CMDIChildWnd* pNewFrame = (CMDIChildWnd*)(GetLayoutTemplate()->CreateNewFrame(m_pFormDoc, NULL)); ASSERT(pNewFrame != NULL); ASSERT_KINDOF(CMDIChildWnd, pNewFrame); pNewFrame->InitialUpdateFrame(m_pFormDoc, TRUE); }