// 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
计数器2
最新推荐文章于 2022-06-03 13:53:16 发布