textviewerdoc.cpp

来自「这是书上的代码」· C++ 代码 · 共 91 行

CPP
91
字号
// TextViewerDoc.cpp :  CTextViewerDoc 类的实现
//

#include "stdafx.h"
#include "TextViewer.h"

#include "TextViewerDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CTextViewerDoc

IMPLEMENT_DYNCREATE(CTextViewerDoc, CDocument)

BEGIN_MESSAGE_MAP(CTextViewerDoc, CDocument)
END_MESSAGE_MAP()


// CTextViewerDoc 构造/销毁

CTextViewerDoc::CTextViewerDoc()
{
	// TODO:在此添加一次性构造代码

}

CTextViewerDoc::~CTextViewerDoc()
{
}

BOOL CTextViewerDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO:在此添加重新初始化代码
	// (SDI 文档将重用该文档)

	return TRUE;
}




// CTextViewerDoc 序列化

void CTextViewerDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO:在此添加存储代码
	}
	else
	{
		// TODO:在此添加加载代码
		CString str;
		while ( ar.ReadString( str ) )
		{
			m_strContent.Add( str );	// 将行文本添加到字符串集合类对象中
		}
	}
}


// CTextViewerDoc 诊断

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

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


// CTextViewerDoc 命令

void CTextViewerDoc::DeleteContents()
{
	// TODO: 在此添加专用代码和/或调用基类
	m_strContent.RemoveAll();		// 清除集合类对象中的内容
	CDocument::DeleteContents();	// 框加自动添加的基类调用
}

⌨️ 快捷键说明

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