ex30view.cpp

来自「一些VC++的经典实例」· C++ 代码 · 共 129 行

CPP
129
字号
// ex30View.cpp : implementation of the CEx30View class
//

#include "stdafx.h"
#include "ex30.h"

#include "ex30Doc.h"
#include "ex30View.h"
#include "card.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEx30View

IMPLEMENT_DYNCREATE(CEx30View, CView)

BEGIN_MESSAGE_MAP(CEx30View, CView)
	//{{AFX_MSG_MAP(CEx30View)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CEx30View construction/destruction

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

}

CEx30View::~CEx30View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CEx30View drawing

void CEx30View::OnDraw(CDC* pDC)
{
	CEx30Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
    lpCCard=pDoc->lpHead;
	int y=4;
	CRect rect;
	
	GetClientRect(&rect);
	CBrush GreenBrush(RGB(0,255,100));

	while((lpCCard=lpCCard->NextCard())!=NULL)
	{
		if(lpCCard==pDoc->lpCurrent)
		{
			rect.top=y-4;
			rect.bottom=y+20;
			
			pDC->FillRect(&rect,&GreenBrush);
		}
		pDC->TextOut(0,y,lpCCard->GetName());
		pDC->TextOut(300,y,lpCCard->GetMail());
		
		y+=20;
	}

	GreenBrush.DeleteObject();
}

/////////////////////////////////////////////////////////////////////////////
// CEx30View printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CEx30View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CEx30View message handlers

⌨️ 快捷键说明

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