计数器2

// count2View.cpp : implementation of the CCount2View class
//

#include "stdafx.h"
#include "count2.h"

#include "count2Doc.h"
#include "count2View.h"

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

/
// CCount2View

IMPLEMENT_DYNCREATE(CCount2View, CView)

BEGIN_MESSAGE_MAP(CCount2View, CView)
	//{{AFX_MSG_MAP(CCount2View)
	ON_WM_RBUTTONDOWN()
	ON_WM_LBUTTONDOWN()
	//}}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()

/
// CCount2View construction/destruction

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

}

CCount2View::~CCount2View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/
// CCount2View drawing

void CCount2View::OnDraw(CDC* pDC)
{
	CCount2Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CString str;
	str.Format("计数:%d",pDoc->nCount);
	pDC->TextOut(10,10,str);
	// TODO: add draw code for native data here
}

/
// CCount2View printing

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

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

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

/
// CCount2View diagnostics

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

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

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

/
// CCount2View message handlers

void CCount2View::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CCount2Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	--pDoc->nCount;
	Invalidate();
	pDoc->SetModifiedFlag();
	CView::OnRButtonDown(nFlags, point);
}

void CCount2View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
    CCount2Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	++pDoc->nCount;
	Invalidate();
	pDoc->SetModifiedFlag();
	CView::OnLButtonDown(nFlags, point);
}



// count2Doc.cpp : implementation of the CCount2Doc class
//

#include "stdafx.h"
#include "count2.h"

#include "count2Doc.h"

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

/
// CCount2Doc

IMPLEMENT_DYNCREATE(CCount2Doc, CDocument)

BEGIN_MESSAGE_MAP(CCount2Doc, CDocument)
	//{{AFX_MSG_MAP(CCount2Doc)
		// 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
END_MESSAGE_MAP()

/
// CCount2Doc construction/destruction

CCount2Doc::CCount2Doc()
{
	// TODO: add one-time construction code here
nCount=0;
}

CCount2Doc::~CCount2Doc()
{
}

BOOL CCount2Doc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)
    nCount=0;
	return TRUE;
}



/
// CCount2Doc serialization

void CCount2Doc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
		ar<<nCount;
	}
	else
	{
		// TODO: add loading code here
		ar>>nCount;
	}
}

/
// CCount2Doc diagnostics

#ifdef _DEBUG
void CCount2Doc::AssertValid() const
{
	CDocument::AssertValid();
}

void CCount2Doc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/
// CCount2Doc commands

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值