📄 ch10demo3doc.cpp
字号:
// Ch10Demo3Doc.cpp : implementation of the CCh10Demo3Doc class
//
#include "stdafx.h"
#include "Ch10Demo3.h"
#include "Ch10Demo3Doc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCh10Demo3Doc
IMPLEMENT_DYNCREATE(CCh10Demo3Doc, CDocument)
BEGIN_MESSAGE_MAP(CCh10Demo3Doc, CDocument)
//{{AFX_MSG_MAP(CCh10Demo3Doc)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CCh10Demo3Doc construction/destruction
CCh10Demo3Doc::CCh10Demo3Doc()
{
// TODO: add one-time construction code here
}
CCh10Demo3Doc::~CCh10Demo3Doc()
{
}
BOOL CCh10Demo3Doc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CCh10Demo3Doc serialization
void CCh10Demo3Doc::Serialize(CArchive& ar)
{
int count;
if (ar.IsStoring())
{
// TODO: add storing code here
count=m_graphlist.GetCount();//获取链表元素数目
ar<<count;//写入序列化对象
POSITION pos = m_graphlist.GetHeadPosition();
for (int i=0;i<count;i++) //遍历链表
{
CGraph* m_pGraph=(CGraph*)m_graphlist.GetNext(pos);
//依次将链表中的元素写入
ar<<m_pGraph->m_star;
ar<<m_pGraph->m_end;
ar<<m_pGraph->m_type;
}
}
else
{
// TODO: add loading code here
if(!m_graphlist.IsEmpty())
m_graphlist.RemoveAll();//清空链表
ar>>count;//读取链表中图形对象的数目
for(int i=0;i<count;i++)
{
CGraph* m_pGraph= new CGraph;//创建结构体对象指针;
ar>>m_pGraph->m_star;//读取数据
ar>>m_pGraph->m_end;
ar>>m_pGraph->m_type;
m_graphlist.AddTail(m_pGraph);//添加至链表
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CCh10Demo3Doc diagnostics
#ifdef _DEBUG
void CCh10Demo3Doc::AssertValid() const
{
CDocument::AssertValid();
}
void CCh10Demo3Doc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCh10Demo3Doc commands
void CCh10Demo3Doc::DeleteContents()
{
// TODO: Add your specialized code here and/or call the base class
if(!m_graphlist.IsEmpty())
m_graphlist.RemoveAll();//清空链表
CDocument::DeleteContents();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -