void CMainFrame::OnView3dview() { CChildFrame *pChildFrame; CW3ZMapEditDoc *pDoc; pChildFrame = (CChildFrame*)MDIGetActive(); if (NULL != pChildFrame) { pDoc = (CW3ZMapEditDoc *)pChildFrame->GetActiveDocument(); pChildFrame = pDoc->Get3DChildFrame(); if (NULL != pChildFrame) { if (TRUE == pChildFrame->IsWindowVisible()) { pChildFrame->ShowWindow(SW_HIDE); } else { pChildFrame->ShowWindow(SW_SHOWNORMAL); } } } }
IComparison* Comparisons::Open(LPCTSTR wdfDocId) { AFX_MANAGE_STATE(AfxGetAppModuleState()); AutomationInteractionSuppressor ais; CMDIFrameWnd* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWnd, AfxGetMainWnd()); GetApp()->RealFileNew(); // TODO - can we get the frame in a better way CChildFrame *pFrame = DYNAMIC_DOWNCAST( CChildFrame, pMainFrame->MDIGetActive() ); if (pFrame) { // TODO - do we need this GetDVController(pFrame)->CloseDocument(true); GetDVController(pFrame)->CloseDocument(false); GetDVController(pFrame)->CloseCompositeDocument(); GetDVController(pFrame)->GetComparisonDocController().CloseComparisonDocument(); if( pFrame->GetCompositeBar() ) pFrame->GetCompositeBar()->OnInitialUpdate(); pFrame->ShowWindow(SW_SHOW); pFrame->BringWindowToTop(); if (!GetDVController(pFrame)->LoadWDF(wdfDocId)) { AfxThrowOleDispatchException(1102, L"File not found : " + CString(wdfDocId)); } pFrame->GetDocument()->UpdateAllViews(NULL); UpdateOpenList(); return FindComObject(pFrame->GetDocument()); } AfxThrowOleDispatchException(1101, L"Internal Error"); return NULL; }
BOOL CStaticDoc::ShowStaticView( CRuntimeClass * pViewClass, BOOL bMaximized ) { if( NULL == pViewClass ) return FALSE; CChildFrame * pChildFrame = NULL; POSITION pos = GetFirstViewPosition( ); CView * pView = NULL; while( pView = GetNextView(pos) ) { if( pView->IsKindOf( pViewClass ) ) { pChildFrame = DYNAMIC_DOWNCAST( CChildFrame, pView->GetParentFrame() ); ASSERT( pChildFrame ); if( pChildFrame ) break; } } if( NULL == pChildFrame ) { // create frame pChildFrame = CChildFrame::CreateNewFrame( this ); ASSERT( pChildFrame ); if( pChildFrame ) { // create view CCreateContext context; context.m_pCurrentDoc = this; context.m_pCurrentFrame = pChildFrame; context.m_pLastView = NULL; context.m_pNewDocTemplate = NULL; context.m_pNewViewClass = pViewClass; CView * pNewView = DYNAMIC_DOWNCAST(CView,pChildFrame->CreateView( &context, AFX_IDW_PANE_FIRST)); if( pNewView ) { pChildFrame->SetActiveView( pNewView ); pNewView->OnInitialUpdate( ); } // if no active child frame, maximize this frame CMainFrame * pMainFrame = AfxGetMainFrame(); if( pMainFrame ) { CFrameWnd * pActiveFrame = AfxGetMainFrame()->GetActiveFrame(); if( !pActiveFrame || !pActiveFrame->IsKindOf(RUNTIME_CLASS(CChildFrame)) ) pChildFrame->MDIMaximize(); } } } if( pChildFrame ) { // activate it pChildFrame->MDIActivate(); if( bMaximized ) pChildFrame->MDIMaximize(); else pChildFrame->ShowWindow( SW_SHOW ); } return TRUE; }