001
05.01.2003, 20:10 Uhr
mike
Pinguinhüpfer (Operator)
|
Hi!
C++: |
void CMainFrame::SwitchToView(int nView) { CView* pOldActiveView = GetActiveView(); CView* pNewActiveView = (CView*) GetDlgItem(nView); if (pNewActiveView == NULL) { switch (nView) { case 1: pNewActiveView = (CView*) new CFirstView; break; case 2: pNewActiveView = (CView*) new CSecView; break; } CCreateContext context; context.m_pCurrentDoc = pOldActiveView->GetDocument(); pNewActiveView->Create(NULL, NULL, WS_BORDER, CFrameWnd::rectDefault, this, nView, &context); pNewActiveView->OnInitialUpdate(); } SetActiveView(pNewActiveView); pNewActiveView->ShowWindow(SW_SHOW); pOldActiveView->ShowWindow(SW_HIDE); pOldActiveView->SetDlgCtrlID( pOldActiveView->GetRuntimeClass() == RUNTIME_CLASS(CFirstView) ? 1 : 2); pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST); RecalcLayout(); }
|
Aufrufen kann mans von überall:
C++: |
CMainFrame* pMain = (CMainFarme*)AfxGetMainWnd(); pMain->SwitchToView(1);
|
mfg mike --
|