现存的CView对象已经和Doc对象关联上,要求生成CFormView对象的代码在CView的操作代码里面。最好给出例子代码,要不给点关键位置的代码也行,谢谢了··

解决方案 »

  1.   

    //在应用类的InitInstance,直接修改文档视图模板就可以了,以下例子创建了两个模板,在启动时会让用户选择那个模板。你直接用CFormView的派生类替代CView的派生类然后创建模板即可BOOL CMyTestApp::InitInstance()
    {
    // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif // Change the registry key under which our settings are stored.
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization.
    SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings();  // Load standard INI file options (including MRU) // Register the application's document templates.  Document templates
    //  serve as the connection between documents, frame windows and views. pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CClientTestDoc),
    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    RUNTIME_CLASS(CClientTestView));
    AddDocTemplate(pDocTemplate);
    pMyListDocTemplate=new CSingleDocTemplate(IDR_LISTFRAME,RUNTIME_CLASS(CSockClientTestDoc),
    RUNTIME_CLASS(CMainFrame),
    RUNTIME_CLASS(CMyTextListView));
    AddDocTemplate(pMyListDocTemplate);
    //pMyListDocTemplate=new CSingleDocTemplate(
    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    return FALSE; // The one and only window has been initialized, so show and update it.
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow(); return TRUE;
    }
      

  2.   

    能不能在CView的操作中动态的将CFormView创建出来,可能吗?
      

  3.   

    没人知道么?
    谁来教教我怎么在CView上画一个CFormView啊!急啊~
      

  4.   

    //请参考以下代码
    //切换
    CView * CMyView::SwitchView(int vViewId)
    {
    CView *pSwitchView;
    CRightFrame *m_pRightFrame= DYNAMIC_DOWNCAST(CRightFrame, m_wndSplitter.GetPane(0, 1));
    if(!m_pRightFrame)
    return NULL;
    pSwitchView=m_pRightFrame->SwitchView(vViewId);
    return pSwitchView;}
    //SwitchView实现
    CView * CRightFrame::SwitchView(int vnViewId)
    { CView* pOldActiveView = GetActiveView();
    CView* pNewActiveView = NULL; switch (vnViewId)
    {
    case VIEW_OUTLOOKDESC:
    pNewActiveView = (CView*) m_pDescView;
    break; case VIEW_OUTLOOKLIST:
    pNewActiveView = (CView*) m_pListView;
    break;
    case VIEW_DAYPLAN:
    pNewActiveView = (CView *)m_pDayPlanView;
    break;
    case VIEW_LEFT:
    pNewActiveView = (CView*) m_pLeftView;
    break;
    case VIEW_HTML:
    pNewActiveView = (CView*) m_pHtmlView;
    break; }
    if (pNewActiveView)
    {
    // don't switch when views are the same
    if (pOldActiveView == pNewActiveView) return pNewActiveView; SetActiveView(pNewActiveView);
    pNewActiveView->ShowWindow(SW_SHOW);
    pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
    pOldActiveView->ShowWindow(SW_HIDE);
    pOldActiveView->SetDlgCtrlID(m_nCurrentViewID);
    m_nCurrentViewID = vnViewId; RecalcLayout();
    }
    return pNewActiveView;

    }
      

  5.   

    http://www.vckbase.com/document/viewdoc/?id=691