📄 ex_docviewview.cpp
字号:
// Ex_DocViewView.cpp : implementation of the CEx_DocViewView class
//
#include "stdafx.h"
#include "Ex_DocView.h"
#include "Ex_DocViewDoc.h"
#include "Ex_DocViewView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx_DocViewView
IMPLEMENT_DYNCREATE(CEx_DocViewView, CFormView)
BEGIN_MESSAGE_MAP(CEx_DocViewView, CFormView)
//{{AFX_MSG_MAP(CEx_DocViewView)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_NEXT, OnNext)
//}}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_DocViewView construction/destruction
CEx_DocViewView::CEx_DocViewView()
: CFormView(CEx_DocViewView::IDD)
{
//{{AFX_DATA_INIT(CEx_DocViewView)
m_sName = _T("");
m_lAge = 0;
m_lScore = 0;
m_nCode = 0;
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CEx_DocViewView::~CEx_DocViewView()
{
}
void CEx_DocViewView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEx_DocViewView)
DDX_Text(pDX, IDC_NAME, m_sName);
DDX_Text(pDX, IDC_AGE, m_lAge);
DDX_Text(pDX, IDC_SCORE, m_lScore);
DDX_Text(pDX, IDC_CODE, m_nCode);
//}}AFX_DATA_MAP
}
BOOL CEx_DocViewView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CEx_DocViewView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CEx_DocViewView printing
BOOL CEx_DocViewView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx_DocViewView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx_DocViewView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CEx_DocViewView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CEx_DocViewView diagnostics
#ifdef _DEBUG
void CEx_DocViewView::AssertValid() const
{
CFormView::AssertValid();
}
void CEx_DocViewView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CEx_DocViewDoc* CEx_DocViewView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx_DocViewDoc)));
return (CEx_DocViewDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx_DocViewView message handlers
void CEx_DocViewView::OnAdd()
{
UpdateData();
CEx_DocViewDoc *pDoc=GetDocument();
ASSERT_VALID(pDoc);
CStudent *pStudent;
pStudent=new CStudent(m_nCode,m_sName,m_lAge,m_lScore);
pDoc->m_dataList.AddTail(pStudent);
pDoc->curPos=pDoc->m_dataList.GetHeadPosition();
}
void CEx_DocViewView::OnNext()
{
CEx_DocViewDoc *pDoc =GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->curPos!=NULL)
{
CStudent *pStudent=(CStudent *)pDoc->m_dataList.GetAt(pDoc->curPos);
m_nCode=pStudent->m_nCode;
m_sName=pStudent->m_sName;
m_lAge=pStudent->m_lAge;
m_lScore=pStudent->m_lScore;
UpdateData(false);
pDoc->m_dataList.GetNext(pDoc->curPos);
if(pDoc->curPos==NULL)
pDoc->curPos=pDoc->m_dataList.GetHeadPosition();
}
else
MessageBox("当前列表中没有数据!");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -