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

📄 ex_a8view.cpp

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

#include "stdafx.h"
#include "Ex_A8.h"

#include "Ex_A8Doc.h"
#include "Ex_A8View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEx_A8View

IMPLEMENT_DYNCREATE(CEx_A8View, CFormView)

BEGIN_MESSAGE_MAP(CEx_A8View, CFormView)
	//{{AFX_MSG_MAP(CEx_A8View)
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit)
	ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx_A8View construction/destruction

CEx_A8View::CEx_A8View()
	: CFormView(CEx_A8View::IDD)
{
	//{{AFX_DATA_INIT(CEx_A8View)
	m_nCoorX = 0;
	m_nCoorY = 0;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CEx_A8View::~CEx_A8View()
{
}

void CEx_A8View::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEx_A8View)
	DDX_Control(pDX, IDC_SPIN2, m_wndSpinY);
	DDX_Control(pDX, IDC_SPIN1, m_wndSpinX);
	DDX_Text(pDX, IDC_EDIT1, m_nCoorX);
	DDX_Text(pDX, IDC_EDIT2, m_nCoorY);
	//}}AFX_DATA_MAP
}

BOOL CEx_A8View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CEx_A8View::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

	m_wndSpinX.SetRange(0, 1000);		// 设置旋转按钮控件的范围
	m_wndSpinY.SetRange(0, 1000);

	CEx_A8Doc* pDoc = GetDocument();
	m_nCoorX = pDoc->m_ptCoor.x;	
	m_nCoorY = pDoc->m_ptCoor.y;
	UpdateData(FALSE);
}

/////////////////////////////////////////////////////////////////////////////
// CEx_A8View printing

BOOL CEx_A8View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CEx_A8View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CEx_A8View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CEx_A8View::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CEx_A8View diagnostics

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

void CEx_A8View::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CEx_A8View message handlers

void CEx_A8View::OnChangeEdit() 
{
	if ( this->IsWindowVisible( ) )
	{
		UpdateData(TRUE);
		CEx_A8Doc* pDoc = GetDocument();
		pDoc->m_ptCoor	= CPoint( m_nCoorX, m_nCoorY );
		pDoc->UpdateAllViews(NULL, 2, NULL);	
	}
}

void CEx_A8View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	if (lHint == 1)	{
		CEx_A8Doc* pDoc = GetDocument();
		m_nCoorX = pDoc->m_ptCoor.x;
		m_nCoorY = pDoc->m_ptCoor.y;
		UpdateData(FALSE);				// 在控件中显示
	}
}

⌨️ 快捷键说明

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