📄 doc_viewdoc.cpp
字号:
// Doc_ViewDoc.cpp : implementation of the CDoc_ViewDoc class
//
#include "stdafx.h"
#include "Doc_View.h"
#include "Doc_ViewDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDoc_ViewDoc
IMPLEMENT_DYNCREATE(CDoc_ViewDoc, CDocument)
BEGIN_MESSAGE_MAP(CDoc_ViewDoc, CDocument)
//{{AFX_MSG_MAP(CDoc_ViewDoc)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDoc_ViewDoc construction/destruction
CDoc_ViewDoc::CDoc_ViewDoc()
{
// TODO: add one-time construction code here
}
CDoc_ViewDoc::~CDoc_ViewDoc()
{
}
BOOL CDoc_ViewDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CDoc_ViewDoc serialization
void CDoc_ViewDoc::Serialize(CArchive& ar)
{
int nIndex,nCount;
CPerson* pPerson;
if (ar.IsStoring())
{
nCount = m_PersonArray.GetSize();
ar << nCount;
for(nIndex=0;nIndex<nCount;nIndex++)
{
pPerson = m_PersonArray.GetAt(nIndex);
pPerson->Serialize(ar);
}
}
else
{
ar >> nCount;
m_PersonArray.SetSize(nCount);
for(nIndex=0;nIndex<nCount;nIndex++)
{
pPerson = new CPerson;
pPerson->Serialize(ar);
m_PersonArray.SetAt(nIndex, pPerson);
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CDoc_ViewDoc diagnostics
#ifdef _DEBUG
void CDoc_ViewDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CDoc_ViewDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDoc_ViewDoc commands
PersonArray* CDoc_ViewDoc::GetPersonArray()
{
return &m_PersonArray;
}
void CDoc_ViewDoc::DeleteContents()
{
int nIndex;
CPerson* pPerson;
for(nIndex=0;nIndex<m_PersonArray.GetSize();nIndex++)
{
pPerson = m_PersonArray.GetAt(nIndex);
m_PersonArray.RemoveAt(nIndex);
delete pPerson;
}
CDocument::DeleteContents();
}
void CDoc_ViewDoc::OnUpdateFileSave(CCmdUI* pCmdUI)
{
pCmdUI->Enable(IsModified());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -