Degrave
asked on
How can I switch to an other Formview in a SDI application
I want to make an application with several Formviews. In the tutorial sample "DAOenroll" from the MSDN, you can do it. When I use the same function (SwitchToForm(int nForm), it doesn't work.
Can I switch between formviews like you do it with dialogboxes (With member function ".DoModal")???
This is the SwitchToForm-function:
void CMainFrame::SwitchToForm(i nt nForm)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*)GetDlgItem(nForm);
if (pNewActiveView == NULL)
{
if (nForm == IDW_COURSE_FORM)
pNewActiveView = (CView*)new CCourseForm;
else
pNewActiveView = (CView*)new CSectionForm;
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocumen t();
pNewActiveView->Create(NUL L, NULL, 0L, CFrameWnd::rectDefault,
this, nForm, &context);
pNewActiveView->OnInitialU pdate();
}
SetActiveView(pNewActiveVi ew);
pNewActiveView->ShowWindow (SW_SHOW);
pOldActiveView->ShowWindow (SW_HIDE);
pOldActiveView->SetDlgCtrl ID(
pOldActiveView->GetRuntime Class() == RUNTIME_CLASS(CCourseForm) ?
IDW_COURSE_FORM : IDW_SECTION_FORM);
pNewActiveView->SetDlgCtrl ID(AFX_IDW _PANE_FIRS T);
RecalcLayout();
}
Thanks
Can I switch between formviews like you do it with dialogboxes (With member function ".DoModal")???
This is the SwitchToForm-function:
void CMainFrame::SwitchToForm(i
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*)GetDlgItem(nForm);
if (pNewActiveView == NULL)
{
if (nForm == IDW_COURSE_FORM)
pNewActiveView = (CView*)new CCourseForm;
else
pNewActiveView = (CView*)new CSectionForm;
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocumen
pNewActiveView->Create(NUL
this, nForm, &context);
pNewActiveView->OnInitialU
}
SetActiveView(pNewActiveVi
pNewActiveView->ShowWindow
pOldActiveView->ShowWindow
pOldActiveView->SetDlgCtrl
pOldActiveView->GetRuntime
IDW_COURSE_FORM : IDW_SECTION_FORM);
pNewActiveView->SetDlgCtrl
RecalcLayout();
}
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.