class 点击右健
new class
派生自cview
此时会有两个view
系统会弹出选择框
你要注释调其中(Cmainframe)的一个
然后用下面的代码切换
void CMainFrame::SwitchToView(eView nView)
{
    CView* pOldActiveView = GetActiveView();
    CView* pNewActiveView = (CView*) GetDlgItem(nView);
    if (pNewActiveView == NULL) {
        switch (nView) {
        case STRING:
            pNewActiveView = (CView*) new CStringView;
            break;
        case HEX:
            pNewActiveView = (CView*) new CHexView;
            break;
        }
        CCreateContext context;
        context.m_pCurrentDoc = pOldActiveView->GetDocument();
        pNewActiveView->Create(NULL, NULL, WS_BORDER,
            CFrameWnd::rectDefault, this, nView, &context);
        pNewActiveView->OnInitialUpdate();
    }
    SetActiveView(pNewActiveView);
    pNewActiveView->ShowWindow(SW_SHOW);
    pOldActiveView->ShowWindow(SW_HIDE);
    pOldActiveView->SetDlgCtrlID(
        pOldActiveView->GetRuntimeClass() == 
        RUNTIME_CLASS(CStringView) ? STRING : HEX);
    pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
    RecalcLayout();
}:

解决方案 »

  1.   

    看错了,以上是单文档程序多文档使用以下代码:
    BOOL CEx20dApp::InitInstance()
    {
    AfxEnableControlContainer(); // 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. CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(
    IDR_EX20DTYPE,
    RUNTIME_CLASS(CPoemDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(CStringView));
    AddDocTemplate(pDocTemplate); m_pTemplateHex = new CMultiDocTemplate(
    IDR_EX20DTYPE,
    RUNTIME_CLASS(CPoemDoc),
    RUNTIME_CLASS(CChildFrame),
    RUNTIME_CLASS(CHexView)); // create main MDI Frame window
    CMainFrame* pMainFrame = new CMainFrame;
    if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    return FALSE;
    m_pMainWnd = pMainFrame; // 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 main window has been initialized, so show and update it.
    pMainFrame->ShowWindow(m_nCmdShow);
    pMainFrame->UpdateWindow(); return TRUE;
    }
    void CMainFrame::OnWindowNewHex() 
    {
        CMDIChildWnd* pActiveChild = MDIGetActive();
        CDocument* pDocument;
        if (pActiveChild == NULL ||
                (pDocument = pActiveChild->GetActiveDocument()) == NULL) {
            TRACE("Warning:  No active document for WindowNew command\n");
            AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
            return; // Command failed
        }    // Otherwise, we have a new frame!
        CDocTemplate* pTemplate =
            ((CEx20dApp*) AfxGetApp())->m_pTemplateHex;
        ASSERT_VALID(pTemplate);
        CFrameWnd* pFrame =
            pTemplate->CreateNewFrame(pDocument, pActiveChild);
        if (pFrame == NULL) {
            TRACE("Warning:  failed to create new frame\n");
            AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
            return; // Command failed
        }    pTemplate->InitialUpdateFrame(pFrame, pDocument);

    }
      

  2.   

    先新建该类然后BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    if (m_wndSplitter.CreateStatic(this,1,2)) 
    {
    CRect rect;
    GetClientRect(&rect);
    CSize sizeTree = rect.Size(); sizeTree.cx = rect.Width()/4;  if (m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CView1), sizeTree,pContext))
    {
    if (m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CView2),
    CSize(0,0),pContext))
    {
    return TRUE;
    }
    }
    } return FALSE;
    }
    之后你的两个View都会有效
    可以相应菜单或者窗口消息
      

  3.   

    如SeainBlue(爱海)
    切分窗口也能达到你的要求!!而且可以使用多个切分类,实现任意切分