dumptestview.cpp
来自「文件包含了很多VC实例」· C++ 代码 · 共 149 行
CPP
149 行
// dumpTestView.cpp : implementation of the CDumpTestView class
//
#include "stdafx.h"
#include "dumpTest.h"
#include "dumpTestDoc.h"
#include "dumpTestView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDumpTestView
IMPLEMENT_DYNCREATE(CDumpTestView, CFormView)
BEGIN_MESSAGE_MAP(CDumpTestView, CFormView)
//{{AFX_MSG_MAP(CDumpTestView)
ON_BN_CLICKED(IDC_BUTTON1, OnEnter)
ON_COMMAND(ID_CLEAR, OnClear)
ON_UPDATE_COMMAND_UI(ID_CLEAR, OnUpdateClear)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CDumpTestView construction/destruction
CDumpTestView::CDumpTestView()
: CFormView(CDumpTestView::IDD)
{
//{{AFX_DATA_INIT(CDumpTestView)
m_strName = _T("");
m_nMoney = 0;
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CDumpTestView::~CDumpTestView()
{
}
void CDumpTestView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDumpTestView)
DDX_Text(pDX, IDC_EDIT1, m_strName);
DDX_Text(pDX, IDC_EDIT2, m_nMoney);
//}}AFX_DATA_MAP
}
BOOL CDumpTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CDumpTestView::OnInitialUpdate()
{
UpdateControlsFromDoc();
}
/////////////////////////////////////////////////////////////////////////////
// CDumpTestView printing
BOOL CDumpTestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDumpTestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDumpTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CDumpTestView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CDumpTestView diagnostics
#ifdef _DEBUG
void CDumpTestView::AssertValid() const
{
CFormView::AssertValid();
}
void CDumpTestView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CDumpTestDoc* CDumpTestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDumpTestDoc)));
return (CDumpTestDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDumpTestView message handlers
void CDumpTestView::OnEnter()
{
CDumpTestDoc* pDoc = GetDocument();
UpdateData(TRUE);
pDoc->m_worker.m_nMoney = m_nMoney;
pDoc->m_worker.m_strName = m_strName;
}
void CDumpTestView::OnClear()
{
GetDocument()->m_worker = CWorker(); // "blank" student object
UpdateControlsFromDoc();
}
void CDumpTestView::OnUpdateClear(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->m_worker != CWorker()); // blank?
}
void CDumpTestView::UpdateControlsFromDoc()
{ // called from OnInitialUpdate and OnEditClearAll
CDumpTestDoc* pDoc = GetDocument();
m_nMoney = pDoc->m_worker.m_nMoney;
m_strName = pDoc->m_worker.m_strName;
UpdateData(FALSE); // calls DDX
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?