topwindowview.cpp

来自「visual c 灵感编程的1-20节源码」· C++ 代码 · 共 131 行

CPP
131
字号
// TopWindowView.cpp : implementation of the CTopWindowView class
//

#include "stdafx.h"
#include "TopWindow.h"

#include "TopWindowDoc.h"
#include "TopWindowView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTopWindowView

IMPLEMENT_DYNCREATE(CTopWindowView, CView)

BEGIN_MESSAGE_MAP(CTopWindowView, CView)
	//{{AFX_MSG_MAP(CTopWindowView)
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTopWindowView construction/destruction

CTopWindowView::CTopWindowView()
{
	// TODO: add construction code here

}

CTopWindowView::~CTopWindowView()
{
}

BOOL CTopWindowView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTopWindowView drawing

void CTopWindowView::OnDraw(CDC* pDC)
{
	CTopWindowDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CTopWindowView printing

BOOL CTopWindowView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CTopWindowView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CTopWindowView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CTopWindowView diagnostics

#ifdef _DEBUG
void CTopWindowView::AssertValid() const
{
	CView::AssertValid();
}

void CTopWindowView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CTopWindowDoc* CTopWindowView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTopWindowDoc)));
	return (CTopWindowDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTopWindowView message handlers

BOOL CTopWindowView::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	// Create a pruple brush.
	//创建一个紫色的刷子
	CBrush Brush (RGB (128 , 0 , 128) );
	// Select the brush into the device context .
	//把紫色刷子选进设备环境
	CBrush* pOldBrush = pDC->SelectObject (&Brush);

	// Get the area that needs to be erased .
	创建需要重画的区域
	CRect rcClip;
	pDC ->GetClipBox (&rcClip);
	//Paint the area.
	重画区域
	pDC -> PatBlt (rcClip.left , rcClip.top , rcClip.Width ( ) , rcClip.Height( ) , PATCOPY );
	//Unselect brush out of device context .
	把紫色刷子选出设备环境
	pDC ->SelectObject (pOldBrush );
	// Return nonzero to half fruther processing .
	return TRUE;

	
//	return CView::OnEraseBkgnd(pDC);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?