{
if (!UpdateData())
return;
CMainDoc* pDoc = GetDocument();
COLORREF color = RGB(255 * (m_iColor == 0),
255 * (m_iColor == 1),
255 * (m_iColor == 2));
BOOL bUpdate = FALSE;
if (m_strData != pDoc->m_strData)
{
pDoc->m_strData = m_strData;
bUpdate = TRUE;
}
if (color != pDoc->m_colorData)
{
pDoc->m_colorData = color;
bUpdate = TRUE;
}
if (bUpdate)
{
// if the document stored data then we would call SetModifiedFlag here
pDoc->UpdateAllViews(this);
}
}
/////////////////////////////////////////////////////simpvw.h文件
class CTextView : public CView
{
protected: // create from serialization only
CTextView();
DECLARE_DYNCREATE(CTextView)
// Attributes
public:
CMainDoc* GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMainDoc)));
return (CMainDoc*) m_pDocument;
}
// Operations
public:
// Implementation
public:
virtual ~CTextView();
virtual void OnDraw(CDC* pDC); // overridden to draw this view
// Generated message map functions
protected:
//{{AFX_MSG(CTextView)
afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CColorView : public CView
{
protected: // create from serialization only
CColorView();
DECLARE_DYNCREATE(CColorView)
// Attributes
public:
CMainDoc* GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMainDoc)));
return (CMainDoc*) m_pDocument;
}
// Operations
public:
// Implementation
public:
virtual ~CColorView();
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual void OnActivateView(BOOL bActivate, CView* pActivateView,
CView* pDeactiveView);
// Generated message map functions
protected:
//{{AFX_MSG(CColorView)
afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
////////////////////////////////simpvw.cpp文件;
#include "stdafx.h"
#include "viewex.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////CTextView
IMPLEMENT_DYNCREATE(CTextView, CView)
BEGIN_MESSAGE_MAP(CTextView, CView)
//{{AFX_MSG_MAP(CTextView)
ON_WM_MOUSEACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CTextView construction/destruction
CTextView::CTextView()
{}
CTextView::~CTextView()
{}
void CTextView::OnDraw(CDC* pDC)
{
CMainDoc* pDoc = GetDocument();
CRect rect;
GetClientRect(rect);
pDC->SetTextAlign(TA_BASELINE | TA_CENTER);
pDC->SetTextColor(pDoc->m_colorData);
pDC->SetBkMode(TRANSPARENT);
// center in the window
pDC->TextOut(rect.Width() / 2, rect.Height() / 2,
pDoc->m_strData, pDoc->m_strData.GetLength());
}
int CTextView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
// side-step CView's implementation since we don't want to activate
// this view
return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
////////////////////////// CColorView
IMPLEMENT_DYNCREATE(CColorView, CView)
BEGIN_MESSAGE_MAP(CColorView, CView)
//{{AFX_MSG_MAP(CColorView)
ON_WM_MOUSEACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CColorView construction/destruction
CColorView::CColorView()
{}
CColorView::~CColorView()
{}
void CColorView::OnDraw(CDC* pDC)
{
CMainDoc* pDoc = GetDocument();
CRect rect;
GetClientRect(rect);
// fill the view with the specified color
CBrush br(pDoc->m_colorData);
pDC->FillRect(rect, &br);
}
int CColorView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
// side-step CView's implementation since we don't want to activate
// this view
return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
void CColorView::OnActivateView(BOOL, CView*, CView*)
{
ASSERT(FALSE); // output only view - should never be active
}
///////////////////////////////////////// splitter.h文件;
// CSplitterFrame frame with splitter/wiper
class CSplitterFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CSplitterFrame)
protected:
CSplitterFrame(); // protected constructor used by dynamic creation
// Attributes
protected:
CSplitterWnd m_wndSplitter;
// Implementation
public:
virtual ~CSplitterFrame();
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
// Generated message map functions
//{{AFX_MSG(CSplitterFrame)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CViewExSplitWnd : public CSplitterWnd
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




