www.gusucode.com > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序 > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序/code/C++例题程序/第7章/s7_4/s7_4View.cpp

    //Download by http://www.NewXing.com
// s7_4View.cpp : implementation of the CS7_4View class
//

#include "stdafx.h"
#include "s7_4.h"

#include "s7_4Doc.h"
#include "s7_4View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CS7_4View

IMPLEMENT_DYNCREATE(CS7_4View, CView)

BEGIN_MESSAGE_MAP(CS7_4View, CView)
	//{{AFX_MSG_MAP(CS7_4View)
	ON_WM_MOUSEMOVE()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CS7_4View construction/destruction

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

}

CS7_4View::~CS7_4View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CS7_4View drawing

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

/////////////////////////////////////////////////////////////////////////////
// CS7_4View printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CS7_4View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CS7_4View message handlers

void CS7_4View::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	char		caBuf[80];		//定义字符数组
	CClientDC	oDC(this);		//将当前视图对象定义成设备实例
	sprintf(caBuf, "[%03d,%03d]", point.x, point.y);	//将鼠标坐标值复制到caBuf中
	oDC.TextOut(60, 80, caBuf, strlen(caBuf));			//在(60, 80)处显示鼠标坐标值

	CView::OnMouseMove(nFlags, point);
}