⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countview.cpp

📁 < MFC经典问答>>是微软类库经常遇到的问题
💻 CPP
字号:
// CountView.cpp : implementation of the CCountView class
//

#include "stdafx.h"
#include "RememberDoc.h"

#include "CountDoc.h"
#include "CountView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCountView

IMPLEMENT_DYNCREATE(CCountView, CView)

BEGIN_MESSAGE_MAP(CCountView, CView)
	//{{AFX_MSG_MAP(CCountView)
	ON_WM_LBUTTONDOWN()
	ON_WM_RBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCountView construction/destruction

CCountView::CCountView()
{
	// TODO: add construction code here
}

CCountView::~CCountView()
{
}

/////////////////////////////////////////////////////////////////////////////
// CCountView drawing

void CCountView::OnDraw(CDC* pDC)
{
	CCountDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	CRect rect;
	GetClientRect( &rect );
	pDC->SetTextAlign( TA_CENTER | TA_BASELINE );

	CString s;
	s.Format( "Counter = %d", pDoc->m_nCount );
	pDC->TextOut( rect.right / 2, 30, s );
	pDC->TextOut( rect.right / 2, 60,
			"Click with left or right button" );
}

/////////////////////////////////////////////////////////////////////////////
// CCountView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CCountView message handlers

void CCountView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	GetDocument()->OnCountIncrement();

	CView::OnLButtonDown(nFlags, point);
}

void CCountView::OnRButtonDown(UINT nFlags, CPoint point) 
{
	GetDocument()->OnCountDecrement();

	CView::OnRButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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