RE: CFormView
You need to write a function that does a runtime view switching. Most
probably that function will reside in the frame. Suppose the number of views
is two; A typical function might look like so;
void CMainFrame::SwitchToView(int nView)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*) GetDlgItem(nView);
if (pNewActiveView == NULL)
{
switch (nView) {
case m_nView1:
pNewActiveView = (CView*) new CFirstView;
break;
case m_nView2:
pNewActiveView = (CView*) new CSecondView;
break;
}
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, WS_BORDER | WS_CHILD,
CFrameWnd::rectDefault, this, nView, &context);
pNewActiveView->OnInitialUpdate();
}
SetActiveView(pNewActiveView);
pOldActiveView->SetDlgCtrlID(pOldActiveView->GetRuntimeClass() ==
RUNTIME_CLASS(CFirstView) ? m_nView1 : m_nView2);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pOldActiveView->ShowWindow(SW_HIDE);
pNewActiveView->ShowWindow(SW_SHOW);
RecalcLayout();
}
where m_nView1 and m_nView2 are some constants, e.g. 1 and 2 respectively.
--
======
Arman
"bob@coolgroups.com" wrote:
I created an SDI application, and I replaced the default View class
in the call to create CSingleDocTemplate with a derivative of
CFormView.
This works and shows my form, but occasionally I want the form to
change
on the fly. How do people typically change the form in CFormView
on the fly?