东软实训01-计数器ver1

来源:互联网 发布:requirejs 按需加载js 编辑:程序博客网 时间:2024/05/22 20:25
// homeword1View.cpp : implementation of the CHomeword1View class// 单击左键加1 ,单击右键 减1#include "stdafx.h"#include "homeword1.h"#include "homeword1Doc.h"#include "homeword1View.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CHomeword1ViewIMPLEMENT_DYNCREATE(CHomeword1View, CView)BEGIN_MESSAGE_MAP(CHomeword1View, CView)//{{AFX_MSG_MAP(CHomeword1View)ON_WM_LBUTTONDOWN()ON_WM_RBUTTONDOWN()//}}AFX_MSG_MAP// Standard printing commandsON_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()/////////////////////////////////////////////////////////////////////////////// CHomeword1View construction/destructionCHomeword1View::CHomeword1View():num(0){// TODO: add construction code here}CHomeword1View::~CHomeword1View(){}BOOL CHomeword1View::PreCreateWindow(CREATESTRUCT& cs){// TODO: Modify the Window class or styles here by modifying//  the CREATESTRUCT csreturn CView::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////////////////// CHomeword1View drawingvoid CHomeword1View::OnDraw(CDC* pDC){CHomeword1Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data hereCRect rect;int x, y;GetWindowRect(&rect);x = rect.Width();//得到客户区xy = rect.Height();CString str;str.Format("%d",num);pDC->TextOut(x/2,y/2,str);}/////////////////////////////////////////////////////////////////////////////// CHomeword1View printingBOOL CHomeword1View::OnPreparePrinting(CPrintInfo* pInfo){// default preparationreturn DoPreparePrinting(pInfo);}void CHomeword1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add extra initialization before printing}void CHomeword1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add cleanup after printing}/////////////////////////////////////////////////////////////////////////////// CHomeword1View diagnostics#ifdef _DEBUGvoid CHomeword1View::AssertValid() const{CView::AssertValid();}void CHomeword1View::Dump(CDumpContext& dc) const{CView::Dump(dc);}CHomeword1Doc* CHomeword1View::GetDocument() // non-debug version is inline{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHomeword1Doc)));return (CHomeword1Doc*)m_pDocument;}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CHomeword1View message handlersvoid CHomeword1View::OnLButtonDown(UINT nFlags, CPoint point) {// TODO: Add your message handler code here and/or call defaultnum += 1;this->Invalidate();CView::OnLButtonDown(nFlags, point);}void CHomeword1View::OnRButtonDown(UINT nFlags, CPoint point) {// TODO: Add your message handler code here and/or call defaultnum -= 1;this->Invalidate();CView::OnRButtonDown(nFlags, point);}

原创粉丝点击