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

📄 drawview.cpp

📁 Visual C++应用教程-源代码 本书在复习C++基础知识后
💻 CPP
字号:
// DrawView.cpp : implementation file
//

#include "stdafx.h"
#include "Ex_A8.h"
#include "DrawView.h"
#include "Ex_A8Doc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDrawView

IMPLEMENT_DYNCREATE(CDrawView, CView)

CDrawView::CDrawView()
{
}

CDrawView::~CDrawView()
{
}


BEGIN_MESSAGE_MAP(CDrawView, CView)
	//{{AFX_MSG_MAP(CDrawView)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDrawView drawing

void CDrawView::OnDraw(CDC* pDC)
{
	CEx_A8Doc* pDoc = (CEx_A8Doc*)m_pDocument;
	CRect rc( pDoc->m_ptCoor.x - 5, pDoc->m_ptCoor.y - 5, 
		pDoc->m_ptCoor.x + 5, pDoc->m_ptCoor.y + 5 );
	pDC->FillSolidRect( rc, RGB( 0, 128, 0 ) );
}

/////////////////////////////////////////////////////////////////////////////
// CDrawView diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CDrawView message handlers

void CDrawView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (lHint == 2)	Invalidate();	
}

void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CEx_A8Doc* pDoc = (CEx_A8Doc*)m_pDocument;
	pDoc->m_ptCoor	= point;
	pDoc->UpdateAllViews( NULL, 1 );
	Invalidate();
	
	CView::OnLButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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