ex21doc.cpp
来自「一些VC++的经典实例」· C++ 代码 · 共 105 行
CPP
105 行
// ex21Doc.cpp : implementation of the CEx21Doc class
//
#include "stdafx.h"
#include "ex21.h"
#include "ex21Doc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx21Doc
IMPLEMENT_SERIAL(CFriend,CObject,1)
CFriend::CFriend(CString Name,CString Mail)
{
m_Name=Name;
m_Mail=Mail;
}
void CFriend::Serialize(CArchive & ar)
{
if(ar.IsStoring())
{
ar<<m_Name<<m_Mail;
}
else
{
ar>>m_Name>>m_Mail;
}
}
IMPLEMENT_DYNCREATE(CEx21Doc, CDocument)
BEGIN_MESSAGE_MAP(CEx21Doc, CDocument)
//{{AFX_MSG_MAP(CEx21Doc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx21Doc construction/destruction
CEx21Doc::CEx21Doc()
{
// TODO: add one-time construction code here
m_Friend.m_Name="Default";
m_Friend.m_Mail="Default";
}
CEx21Doc::~CEx21Doc()
{
}
BOOL CEx21Doc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CEx21Doc serialization
void CEx21Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
m_Friend.Serialize(ar);
}
/////////////////////////////////////////////////////////////////////////////
// CEx21Doc diagnostics
#ifdef _DEBUG
void CEx21Doc::AssertValid() const
{
CDocument::AssertValid();
}
void CEx21Doc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx21Doc commands
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?