调用CDocument的UpDateAllViews函数。
解决方案 »
- 关于树形控件和组合框的问题~
- 怎么截取一个制定的Rect中的DC并保存为bmp?
- 双击.ocx或.dll格式的控件的时候,系统在做什么?
- 我编写对话框程序,一开始没有选取winsock支持,现在想用CSocket类,怎么办啊?
- 请问如果对一个没有界面的程序调试
- 怎样把位图转换成工具栏资源
- 打开进程OpenProcess失败了,GetLastError()居然是2
- 请各位帮我看看做一个字符串相关的函数!分数多多!谢谢!!!
- 于视类、SetWindowText()、OnDraw()
- unsigned char转CString
- 有关CView的问题 大虾指教!!!!
- ●●几个简单问题,懒得查书了,一题10分,好赚的很:)●●
视图没有必要删除的
只要 在 CDocument中 调用UpDateAllViews函数。
然后在 View中 调用 WM_UPDATE响应 就完全能够解决同步刷新的 问题了
没有必要删除的
用条目值来传递 视图相应
在没有分割视的框架中,切换视图我是按你的方法来做的。但在有分割视的框架中,好像不太行。
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()
以下代码是你所想要的:
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);
}