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

📄 memodoc.cpp

📁 这些源代码
💻 CPP
字号:
// MemoDoc.cpp : implementation of the CMemoDoc class
//

#include "stdafx.h"
#include "Memo.h"

#include "MemoDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMemoDoc

IMPLEMENT_DYNCREATE(CMemoDoc, CDocument)

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

/////////////////////////////////////////////////////////////////////////////
// CMemoDoc construction/destruction

CMemoDoc::CMemoDoc()
{
	// TODO: add one-time construction code here

}

CMemoDoc::~CMemoDoc()
{
}

BOOL CMemoDoc::OnNewDocument()
{

	if (!CDocument::OnNewDocument())
		return FALSE;

	((CEditView*)m_viewList.GetHead())->SetWindowText(NULL);

	m_MemoData.m_dataCreated = 0;
	m_MemoData.m_dataCreatedBy.Empty ();
	m_MemoData.m_dataReference.Empty ();
	m_MemoData.m_dataSent = 0;
	m_MemoData.m_dataSentTo.Empty ();
	m_MemoData.m_dataSubject.Empty ();

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CMemoDoc serialization

void CMemoDoc::Serialize(CArchive& ar)
{
	CString fn = ar.GetFile()->GetFileName();
	int pos;
	if ((pos = fn.FindOneOf(".")) >= 0)
	{
		pos = fn.GetLength() - pos;
		fn = fn.Right (pos);
		if (!fn.CompareNoCase (".mem"))
		{
			if (ar.IsStoring ())
			{
				ar << m_MemoData;
			}
			else
			{
				DWORD dwHeaderSize;
				ar >> m_MemoData;
				ar >> dwHeaderSize;
				CFile* pFile = ar.GetFile();
				DWORD nFileSize = pFile->GetPosition();
				nFileSize = pFile->GetLength() - dwHeaderSize;
				if (nFileSize/sizeof(TCHAR) > CEditView::nMaxSize)
				{
					AfxMessageBox(AFX_IDP_FILE_TOO_LARGE);
					return;
				}
// ReadFromArchive takes the number of characters as argument
				((CEditView*)m_viewList.GetHead())->ReadFromArchive(ar, (UINT)nFileSize/sizeof(TCHAR));
				return;
			}
		}
	}
	// CEditView contains an edit control which handles all serialization
	((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
}

/////////////////////////////////////////////////////////////////////////////
// CMemoDoc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CMemoDoc commands

void CMemoDoc::ShowHeader()
{
	if (m_MemoData.m_dataCreated == 0)
	{
		m_MemoData.m_dataCreated = CTime::GetCurrentTime ();
		char user[_MAX_PATH];
		DWORD dwSize = _MAX_PATH;
		GetUserName (user, &dwSize);
		m_MemoData.m_dataCreatedBy = user;
	}
	CMemoDlg	md (m_MemoData);
	if (md.DoModal () == IDCANCEL)
		return;
}

⌨️ 快捷键说明

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