⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emailsdoc.cpp

📁 讲mfc的书
💻 CPP
字号:
// emailsDoc.cpp : implementation of the CEmailsDoc class
//

#include "stdafx.h"
#include "emails.h"

#include "emailsDoc.h"
#include "emailsView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////
// CEmailsDoc

IMPLEMENT_DYNCREATE(CEmailsDoc, CDocument)
IMPLEMENT_SERIAL(EMailDB,CObject,VERSIONABLE_SCHEMA|1)

void EMailDB::Serialize(CArchive& ar)
{
	int i;
	if (ar.IsLoading())
	{
		int version=ar.GetObjectSchema();
		if (version!=1)
		{
			AfxMessageBox("Unknown file message");
			return;
		}
		CObject::Serialize(ar);
		ar>>m_count;
		for (i=0;i<=m_count;i++)
		{
			ar>>name[i];
			ar>>email[i];
		}
	}
	else
	{
		CObject::Serialize(ar);
		ar<<m_count;
		for (i=0;i<=m_count;i++)
		{
			ar<<name[i];
			ar<<email[i];
		}
	}
}


BEGIN_MESSAGE_MAP(CEmailsDoc, CDocument)
	//{{AFX_MSG_MAP(CEmailsDoc)
		// 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()

/////////////////////////////
// CEmailsDoc construction/destruction

CEmailsDoc::CEmailsDoc()
{
	db=NULL;
}

CEmailsDoc::~CEmailsDoc()
{
}

BOOL CEmailsDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;
	delete db;
	db=new EMailDB;
	return TRUE;
}



/////////////////////////////
// CEmailsDoc serialization

void CEmailsDoc::Serialize(CArchive& ar)
{
	CObject *ob;
	if (ar.IsStoring())
	{
		ar<<db;
	}
	else
	{
		ar>>ob;
		db=(EMailDB *)ob;
		CEmailsView *v;
		POSITION pos;
		pos=GetFirstViewPosition();
		v=(CEmailsView *)GetNextView(pos);
		v->m_current=0;
		v->UpdateView();
	}
}

/////////////////////////////
// CEmailsDoc diagnostics

#ifdef _DEBUG
void CEmailsDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CEmailsDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////
// CEmailsDoc commands


void CEmailsDoc::DeleteContents() 
{
	delete db;	
	CDocument::DeleteContents();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -