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

📄 drawformview.cpp

📁 这是MFC经典问答书的光盘内容
💻 CPP
字号:
// DrawFormView.cpp : implementation file
//

#include "stdafx.h"
#include "TwoViews.h"

#include "DrawFormView.h"
#include "DrawDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDrawFormView

IMPLEMENT_DYNCREATE(CDrawFormView, CFormView)

CDrawFormView::CDrawFormView()
	: CFormView(CDrawFormView::IDD)
{
	//{{AFX_DATA_INIT(CDrawFormView)
	m_strCurrentShape = _T("");
	m_nCurrentY = 0;
	m_nCurrentX = 0;
	//}}AFX_DATA_INIT
}

CDrawFormView::~CDrawFormView()
{
}

void CDrawFormView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDrawFormView)
	DDX_Text(pDX, IDC_SHAPE, m_strCurrentShape);
	DDX_Text(pDX, IDC_Y, m_nCurrentY);
	DDX_Text(pDX, IDC_X, m_nCurrentX);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDrawFormView, CFormView)
	//{{AFX_MSG_MAP(CDrawFormView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDrawFormView diagnostics

#ifdef _DEBUG
void CDrawFormView::AssertValid() const
{
	CFormView::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CDrawFormView message handlers

void CDrawFormView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// 1 - Get the current data from our document
	CDrawDoc* pDoc = static_cast< CDrawDoc* >( GetDocument() );
	ASSERT_KINDOF( CDrawDoc, pDoc );

	m_nCurrentX = pDoc->m_point.x;
	m_nCurrentY = pDoc->m_point.x;

	switch( pDoc->m_shape )
	{
	default :
		ASSERT( FALSE );	// This should never happen !
		break;

	case CDrawDoc::CIRCLE :
		m_strCurrentShape = "Circle";
		break;

	case CDrawDoc::SQUARE :
		m_strCurrentShape = "Square";
		break;
	}

	// 2 - Show the current data in our edit controls
	UpdateData( FALSE );
}

⌨️ 快捷键说明

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