Link to home
Start Free TrialLog in
Avatar of Degrave
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(int 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->GetDocument();
            pNewActiveView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault,
                  this, nForm, &context);
            pNewActiveView->OnInitialUpdate();
      }

      SetActiveView(pNewActiveView);
      pNewActiveView->ShowWindow(SW_SHOW);
      pOldActiveView->ShowWindow(SW_HIDE);
      pOldActiveView->SetDlgCtrlID(
            pOldActiveView->GetRuntimeClass() == RUNTIME_CLASS(CCourseForm) ?
            IDW_COURSE_FORM : IDW_SECTION_FORM);
      pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
      RecalcLayout();
}

Thanks
ASKER CERTIFIED SOLUTION
Avatar of bhat
bhat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial