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

📄 exam8_2view.cpp

📁 This is Visual C++ basis operation. Using that you can fast go in study.
💻 CPP
字号:
// Exam8_2View.cpp : implementation of the CExam8_2View class
//

#include "stdafx.h"
#include "Exam8_2.h"

#include "Exam8_2Doc.h"
#include "Exam8_2View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CExam8_2View

IMPLEMENT_DYNCREATE(CExam8_2View, CFormView)

BEGIN_MESSAGE_MAP(CExam8_2View, CFormView)
	//{{AFX_MSG_MAP(CExam8_2View)
	ON_BN_CLICKED(IDC_ENTER, OnEnter)
	ON_COMMAND(ID_EDIT_CLEAR_ALL, OnEditClearAll)
	ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR_ALL, OnUpdateEditClearAll)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CExam8_2View construction/destruction

CExam8_2View::CExam8_2View()
	: CFormView(CExam8_2View::IDD)
{
	//{{AFX_DATA_INIT(CExam8_2View)
	m_Name = _T("");
	m_Grade = 0;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CExam8_2View::~CExam8_2View()
{
}

void CExam8_2View::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CExam8_2View)
	DDX_Text(pDX, IDC_NAME, m_Name);
	DDX_Text(pDX, IDC_GRADE, m_Grade);
	DDV_MinMaxInt(pDX, m_Grade, 0, 100);
	//}}AFX_DATA_MAP
}

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

	return CFormView::PreCreateWindow(cs);
}

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

	UpdateControlsFromDoc();

}

/////////////////////////////////////////////////////////////////////////////
// CExam8_2View printing

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

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CExam8_2View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CExam8_2View message handlers

void CExam8_2View::OnEnter() 
{
	// TODO: Add your control notification handler code here
	CExam8_2Doc*pDoc=GetDocument();	
	UpdateData(true);	
	pDoc->m_Student.m_Grade=m_Grade;	
	pDoc->m_Student.m_Name=m_Name;
}

void CExam8_2View::OnEditClearAll() 
{
	// TODO: Add your command handler code here
	GetDocument()->m_Student=CStudent();	
	UpdateControlsFromDoc();
}

void CExam8_2View::OnUpdateEditClearAll(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(GetDocument()->m_Student!=CStudent());
}

void CExam8_2View::UpdateControlsFromDoc()
{
    //called from OnInitialUpdate and OnEditClearAll	
	CExam8_2Doc*pDoc=GetDocument();
	//把文档中的数据传输到视图类的数据成员	
	m_Grade=pDoc->m_Student.m_Grade;	
	m_Name=pDoc->m_Student.m_Name;	
	UpdateData(false);// 传送到窗体中的编辑控件
}

⌨️ 快捷键说明

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