创建了一个工程
SDI 的 包含多个View。(CListView、CEditView)
查找了codeguru、和codeproject。
试了几个例子。效果一般。
1、谁有好的例子 发给我看看 谢谢。
2、工程是基于CListView建立的,CListView 预览、打印正常。
   可是在自己建的CEditView 类中如何加入预览、打印功能?
谢谢[email protected]

解决方案 »

  1.   

    在http://www.yesky.com/97/1779597.shtml有一个帖子"用VC++在单文档界面中创建多视图",可以建立多视图,也可以切换。
    我顺便在此问一个问题:但是视图在切换后鼠标事件不响应了,不知到什么原因?
      

  2.   

    加入打印预览:
    //BEGIN_MESSAGE_MAP(CtestView, CListView)
    // 标准打印命令
    ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
    //END_MESSAGE_MAP()加入这三个命令映射,另外在菜单里添加相应菜单.
      

  3.   

    void CMainFrame::OnViewChange(UINT nCmdID) 
    {
    if (nCmdID == m_nCurrentView)
    return;  // already selected
    // m_nCurrentView = nCmdID; // Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
    // This is necessary so that CFrameWnd::RecalcLayout will allocate
    // this "first pane" to that portion of the frame window's client
    // area not allocated to control bars.  Set the child ID of
    // the previously active view to some other ID; we will use the
    // command ID as the child ID.
    CView* pOldActiveView = GetActiveView();
    ::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, m_nCurrentView); CView* pNewView = NULL;
    CDocument* pDoc = GetActiveDocument();
    CRuntimeClass* pNewViewClass;
    switch (nCmdID)
    {
    case ID_VIEW_MAIN:
    pNewView = m_pViewMain;
    pNewViewClass = RUNTIME_CLASS(CMainView);
    break;
    case ID_VIEW_AUTO:
    pNewView = m_pViewAuto;
    pNewViewClass = RUNTIME_CLASS(CAutoView);
    break;
    case ID_VIEW_MAKE:
    pNewView = m_pViewMake;
    pNewViewClass = RUNTIME_CLASS(CMakeView);
    break;
    default:
    ASSERT(0);
    return;
    } if (pNewView == NULL)
    {
    // create the new view
    CCreateContext context;
    context.m_pNewViewClass = pNewViewClass;
    context.m_pCurrentDoc = pDoc;
    pNewView = STATIC_DOWNCAST(CView, CreateView(&context));
    if (pNewView != NULL)
    {
    pNewView->ShowWindow(SW_SHOW);
    pOldActiveView->ShowWindow(SW_HIDE); pNewView->OnInitialUpdate();
    SetActiveView(pNewView);
    RecalcLayout();
    }
    }
    else// if (pNewView != NULL)
    {
    pNewView->ShowWindow(SW_SHOW);
    pOldActiveView->ShowWindow(SW_HIDE);
    } SetActiveView(pNewView);
    m_nCurrentView = nCmdID;
    // finally destroy the old view...
    // pOldActiveView->DestroyWindow();
    }单文档多视图切换,的一个函数,相信你可以看懂.