1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| void CMainFrame::SelectView(int ViewID)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = static_cast<CView*>( GetDlgItem(ViewID) );
if(pNewActiveView == NULL)
{
switch(ViewID)
{
case ID_FORMVIEW1:
pNewActiveView = new CFormView1();
break;
case ID_FORMVIEW2:
pNewActiveView = new CFormView2();
break;
case ID_FORMVIEW3:
pNewActiveView = new CFormView3();
break;
default:
AfxMessageBox("ID de vue invalide");
return;
}
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault, this, ViewID, &context);
pNewActiveView->OnInitialUpdate();
}
SetActiveView(pNewActiveView);
pOldActiveView->ShowWindow(SW_HIDE);
pNewActiveView->ShowWindow(SW_SHOW);
pOldActiveView->SetDlgCtrlID(m_CurrentViewID);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
m_CurrentViewID = ViewID;
RecalcLayout();
} |
Partager