调用CDocument的UpDateAllViews函数。

解决方案 »

  1.   

    同意楼上的观点
    视图没有必要删除的 
    只要 在 CDocument中 调用UpDateAllViews函数。
     然后在  View中 调用 WM_UPDATE响应 就完全能够解决同步刷新的 问题了
    没有必要删除的 
    用条目值来传递 视图相应
      

  2.   

    对啊,要实现视图的切换,没有必要删除旧的视图。你用SetDlgCtrlID把每个视图都设置一个不同的ID,要切换的时候只要根据ID值用ShowWindow()把旧的视图隐藏并把新的视图显示出来,然后用SetActiveView来设置活动的视图就行了(把活动视图的ID设为IDW_PANE_FIRST)。
      

  3.   

    to webber84(糕鱼昏):
     在没有分割视的框架中,切换视图我是按你的方法来做的。但在有分割视的框架中,好像不太行。
      

  4.   

    // splitex.h
    class CSplitterWndEx : public CSplitterWnd
    {
    protected:
         int m_nHidedCol;  // hided column number, -1 if all columns
    // are shownpublic:
         CSplitterWndEx();    void ShowColumn();
        void HideColumn(int colHide);// ClassWizard generated virtual function overrides
         //{{AFX_VIRTUAL(CSplitterWndEx)
         //}}AFX_VIRTUAL// Generated message map functions
    protected:
         //{{AFX_MSG(CSplitterWndEx)
          // NOTE - the ClassWizard will add and remove
          //member functions here.
         //}}AFX_MSG    DECLARE_MESSAGE_MAP()
    };/////////////////////////////////////////////////////////////////
    /
    // splitex.cpp#include "stdafx.h"
    #include "splitex.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif///////////////////////////////////////////////////////////////
    /
    // CSplitterWndExCSplitterWndEx::CSplitterWndEx() :
        m_nHidedCol(-1)
    {
    }void CSplitterWndEx::ShowColumn()
    {
         ASSERT_VALID(this);
         ASSERT(m_nCols < m_nMaxCols);
         ASSERT(m_nHidedCol != -1);     int colNew = m_nHidedCol;
         m_nHidedCol = -1;
         int cxNew = m_pColInfo[m_nCols].nCurSize;
         m_nCols++;  // add a column
         ASSERT(m_nCols == m_nMaxCols);    // fill the hided column
         int col;
         for (int row = 0; row < m_nRows; row++)
         {
              CWnd* pPaneShow = GetDlgItem(
                   AFX_IDW_PANE_FIRST + row * 16 + m_nCols);
              ASSERT(pPaneShow != NULL);
              pPaneShow->ShowWindow(SW_SHOWNA);          for (col = m_nCols - 2; col >= colNew; col--)
              {
                   CWnd* pPane = GetPane(row, col);
                   ASSERT(pPane != NULL);
                   pPane->SetDlgCtrlID(IdFromRowCol(row, col + 1));
              }         pPaneShow->SetDlgCtrlID(IdFromRowCol(row, colNew));
         }    // new panes have been created -- recalculate layout
         for (col = colNew + 1; col < m_nCols; col++)
             m_pColInfo[col].nIdealSize =
                      m_pColInfo[col - 1].nCurSize;
         m_pColInfo[colNew].nIdealSize = cxNew;
         RecalcLayout();
    }void CSplitterWndEx::HideColumn(int colHide)
    {
         ASSERT_VALID(this);
         ASSERT(m_nCols > 1);
         ASSERT(colHide < m_nCols);
         ASSERT(m_nHidedCol == -1);
         m_nHidedCol = colHide;    // if the column has an active window -- change it
         int rowActive, colActive;
         if (GetActivePane(&rowActive, &colActive) != NULL &&
             colActive == colHide)
         {
              if (++colActive >= m_nCols)
                  colActive = 0;
              SetActivePane(rowActive, colActive);
         }    // hide all column panes
         for (int row = 0; row < m_nRows; row++)
         {
              CWnd* pPaneHide = GetPane(row, colHide);
              ASSERT(pPaneHide != NULL);
              pPaneHide->ShowWindow(SW_HIDE);
              pPaneHide->SetDlgCtrlID(AFX_IDW_PANE_FIRST + row * 16 + m_nCols);          for (int col = colHide + 1; col < m_nCols; col++)
              {
                   CWnd* pPane = GetPane(row, col);
                   ASSERT(pPane != NULL);
                   pPane->SetDlgCtrlID(IdFromRowCol(row, col - 1));
              }
         }
         m_nCols--;
         m_pColInfo[m_nCols].nCurSize = m_pColInfo[colHide].nCurSize;
         RecalcLayout();
    }BEGIN_MESSAGE_MAP(CSplitterWndEx, CSplitterWnd)
    //{{AFX_MSG_MAP(CSplitterWndEx)
      // NOTE - the ClassWizard will add and remove mapping macros here.
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
      

  5.   

    发错了
    以下代码是你所想要的:
    class CExSplitterWnd : public CSplitterWnd
    {
    // Construction
    public:
        CExSplitterWnd();
    // Overrides
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CExSplitterWnd)
        //}}AFX_VIRTUAL
    // Implementation
        virtual ~CExSplitterWnd();
        BOOL AttachView(CWnd* pView, int row, int col);
        BOOL DetachView(int row, int col);
        // Generated message map functions
        //{{AFX_MSG(CExSplitterWnd)
            // NOTE - the ClassWizard will add and remove member functions here.
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
    };
    CExSplitterWnd::CExSplitterWnd()
    {
    }
    CExSplitterWnd::~CExSplitterWnd()
    {
    }
    BOOL CExSplitterWnd::AttachView(CWnd* pView, int row, int col)
    {
        //Make sure the splitter window was created
        if (!IsWindow(m_hWnd))
        {
            ASSERT(0);
            TRACE(_T("Create the splitter window before attaching windows to panes"));
            return (FALSE);
        }    //Make sure the row and col indices are within bounds
        if (row >= GetRowCount() || col >= GetColumnCount())
        {
            ASSERT(0);
            return FALSE;
        }    //Is the window to be attached a valid one
        if (pView == NULL || (!IsWindow(pView->m_hWnd)))
        {
            ASSERT(0);
            return FALSE;
        }    pView->SetDlgCtrlID(IdFromRowCol(row, col));
        pView->SetParent(this);
        pView->ShowWindow(SW_SHOW);
        pView->UpdateWindow();
        return (TRUE);
    }
    BOOL CExSplitterWnd::DetachView(int row, int col)
    {
        //Make sure the splitter window was created
        if (!IsWindow(m_hWnd))
        {
            ASSERT(0);
            TRACE(_T("Create the splitter window before attaching windows to panes"));
            return (FALSE);
        }
        //Make sure the row and col indices are
        //within bounds
        if (row >= GetRowCount() || col >= GetColumnCount())
        {
            ASSERT(0);
            return FALSE;
        }
        CWnd* pWnd = GetPane(row, col);
        if (pWnd == NULL || (!IsWindow(pWnd->m_hWnd)))
        {
            ASSERT(0);
            return FALSE;
        }
        pWnd->ShowWindow(SW_HIDE);
        pWnd->UpdateWindow();
        //Set the parent window handle to NULL so that this child window is not
        //destroyed when the parent (splitter) is destroyed
        pWnd->SetParent(NULL);
        return (TRUE);
    }
      

  6.   

    to coffeefish(咖啡鱼): 发到我的信箱[email protected], 谢谢