locked
multi view

    Domanda

  • hi,

    i have  an MFC program, i used this code in CMainFrame to switch views 

    void CMainFrame::SwitchToView(int nView)

    {
         CView* pOldActiveView = GetActiveView();
         CView* pNewActiveView = (CView*)GetDlgItem(nView);
         if (pNewActiveView == NULL) 
         {
              switch(nView)
              {
              case IDD_FORMVIEW:
                   pNewActiveView = (CView*) new CNewView;
                   break;
              case IDD_MULTIVIEW_FORM:
                   pNewActiveView = (CView*) new CMultiViewView;
                   break;
              case IDD_FORMVIEW1:
                   pNewActiveView = (CView*) new CNewExtraFrm;
                   break;
              }
              CCreateContext context;
              context.m_pCurrentDoc = pOldActiveView->GetDocument();
              pNewActiveView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault,this, nView, &context);
              pNewActiveView->OnInitialUpdate();
         }
         SetActiveView(pNewActiveView);
         pNewActiveView->ShowWindow(SW_SHOW);
         pOldActiveView->ShowWindow(SW_HIDE);
    switch(nView)
    {
    case IDD_FORMVIEW:
    pOldActiveView->SetDlgCtrlID( IDD_FORMVIEW);
    break;
    case IDD_MULTIVIEW_FORM:
    pOldActiveView->SetDlgCtrlID( IDD_MULTIVIEW_FORM);
    break;
    case IDD_FORMVIEW1:
    pOldActiveView->SetDlgCtrlID( IDD_FORMVIEW1);
    break;
    }

         pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
         RecalcLayout();
    delete pOldActiveView;
    }

    void CMainFrame:: OnViiw1()//  OnViiw2 // OnViiw3 ...
    {
    if (GetActiveView()->IsKindOf(RUNTIME_CLASS(CMultiViewView)))
    return; // already active
    SwitchToView(IDD_MULTIVIEW_FORM); // originALE
    }


    void CMainFrame::OnUpdateTestViiworiginale(CCmdUI *pCmdUI) ...
    {
    pCmdUI->SetCheck(GetActiveView()->IsKindOf(RUNTIME_CLASS(CMultiViewView)));
    }

    now i would like to add new view ( cformview with split and clistview ) how can i do it 

    thanks in advance 


    Gio

    lunedì 12 marzo 2012 16:53

Risposte

  • "cformview with split and clistview" is not a view, it's quite a bit more complicated than that and will not be compatible with your exixting code.

    The sample code linked in this article includes switching with splitters:

    http://support.microsoft.com/kb/199515/r

    • Contrassegnato come risposta Gio71 martedì 13 marzo 2012 15:11
    lunedì 12 marzo 2012 22:27

Tutte le risposte

  • "cformview with split and clistview" is not a view, it's quite a bit more complicated than that and will not be compatible with your exixting code.

    The sample code linked in this article includes switching with splitters:

    http://support.microsoft.com/kb/199515/r

    • Contrassegnato come risposta Gio71 martedì 13 marzo 2012 15:11
    lunedì 12 marzo 2012 22:27
  • Maybe you could create another form view with the list and tree controls and use a technique like in this (older) article to do the splitter for that dialog.

    http://www.codeguru.com/cpp/w-d/splitter/article.php/c1555

    Tom

    lunedì 12 marzo 2012 22:47
  • thanks this may help me a lot 


    Gio

    martedì 13 marzo 2012 11:20