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

📄 sdifortxtdoc.cpp

📁 初学时编写的一个简单的单文件文本编辑器 功能简单
💻 CPP
字号:
// SDIforTXTDoc.cpp : implementation of the CSDIforTXTDoc class
//

#include "stdafx.h"
#include "SDIforTXT.h"

#include "SDIforTXTDoc.h"
#include "CntrItem.h"
#include "SrvrItem.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSDIforTXTDoc

IMPLEMENT_DYNCREATE(CSDIforTXTDoc, CRichEditDoc)

BEGIN_MESSAGE_MAP(CSDIforTXTDoc, CRichEditDoc)
	//{{AFX_MSG_MAP(CSDIforTXTDoc)
		// 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
	// Enable default OLE container implementation
	ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_LINKS, CRichEditDoc::OnUpdateEditLinksMenu)
	ON_COMMAND(ID_OLE_EDIT_LINKS, CRichEditDoc::OnEditLinks)
	ON_UPDATE_COMMAND_UI_RANGE(ID_OLE_VERB_FIRST, ID_OLE_VERB_LAST, CRichEditDoc::OnUpdateObjectVerbMenu)
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CSDIforTXTDoc, CRichEditDoc)
	//{{AFX_DISPATCH_MAP(CSDIforTXTDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//      DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_ISDIforTXT to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {D76DA28D-B927-4B0B-81E3-12F1D60C7DCB}
static const IID IID_ISDIforTXT =
{ 0xd76da28d, 0xb927, 0x4b0b, { 0x81, 0xe3, 0x12, 0xf1, 0xd6, 0xc, 0x7d, 0xcb } };

BEGIN_INTERFACE_MAP(CSDIforTXTDoc, CRichEditDoc)
	INTERFACE_PART(CSDIforTXTDoc, IID_ISDIforTXT, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSDIforTXTDoc construction/destruction

CSDIforTXTDoc::CSDIforTXTDoc()
{
	// Use OLE compound files
	EnableCompoundFile();

	// TODO: add one-time construction code here

	EnableAutomation();

	AfxOleLockApp();
}

CSDIforTXTDoc::~CSDIforTXTDoc()
{
	AfxOleUnlockApp();
}

BOOL CSDIforTXTDoc::OnNewDocument()
{
	if (!CRichEditDoc::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}

CRichEditCntrItem* CSDIforTXTDoc::CreateClientItem(REOBJECT* preo) const
{
	// cast away constness of this
	return new CSDIforTXTCntrItem(preo, (CSDIforTXTDoc*) this);
}

/////////////////////////////////////////////////////////////////////////////
// CSDIforTXTDoc server implementation

COleServerItem* CSDIforTXTDoc::OnGetEmbeddedItem()
{
	// OnGetEmbeddedItem is called by the framework to get the COleServerItem
	//  that is associated with the document.  It is only called when necessary.

	CSDIforTXTSrvrItem* pItem = new CSDIforTXTSrvrItem(this);
	ASSERT_VALID(pItem);
	return pItem;
}

/////////////////////////////////////////////////////////////////////////////
// CSDIforTXTDoc Active Document server implementation

CDocObjectServer *CSDIforTXTDoc::GetDocObjectServer(LPOLEDOCUMENTSITE pDocSite)
{
	return new CDocObjectServer(this, pDocSite);
}



/////////////////////////////////////////////////////////////////////////////
// CSDIforTXTDoc serialization

void CSDIforTXTDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}

	// Calling the base class CRichEditDoc enables serialization
	//  of the container document's COleClientItem objects.
	// TODO: set CRichEditDoc::m_bRTF = FALSE if you are serializing as text
	CRichEditDoc::Serialize(ar);
}

/////////////////////////////////////////////////////////////////////////////
// CSDIforTXTDoc diagnostics

#ifdef _DEBUG
void CSDIforTXTDoc::AssertValid() const
{
	CRichEditDoc::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CSDIforTXTDoc commands

⌨️ 快捷键说明

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