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

📄 graphicdoc.cpp

📁 VC深入详解code.rar
💻 CPP
字号:
// GraphicDoc.cpp : implementation of the CGraphicDoc class
//

#include "stdafx.h"
#include "Graphic.h"

#include "GraphicDoc.h"
#include "GraphicView.h"
#include "Graph.h"

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

/////////////////////////////////////////////////////////////////////////////
// CGraphicDoc

IMPLEMENT_DYNCREATE(CGraphicDoc, CDocument)

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

/////////////////////////////////////////////////////////////////////////////
// CGraphicDoc construction/destruction

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

}

CGraphicDoc::~CGraphicDoc()
{
}

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

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)
//	SetTitle("http://www.sunxin.org");

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CGraphicDoc serialization

void CGraphicDoc::Serialize(CArchive& ar)
{
	POSITION pos=GetFirstViewPosition();
	CGraphicView *pView=(CGraphicView*)GetNextView(pos);
	if (ar.IsStoring())
	{
		// TODO: add storing code here
/*		int i=5;
		char ch='b';
		float f=1.2f;
		CString str("http://www.sunxin.org");
		ar<<i<<ch<<f<<str;
*/
/*		int nCount=pView->m_obArray.GetSize();
		ar<<nCount;
		for(int i=0;i<nCount;i++)
		{
			ar<<pView->m_obArray.GetAt(i);
		}
*/
	}
	else
	{
		// TODO: add loading code here
	/*	int i;
		char ch;
		float f;
		CString str;
		CString strResult;
		ar>>i>>ch>>f>>str;
		strResult.Format("%d,%c,%f,%s",i,ch,f,str);
		AfxMessageBox(strResult);
	*/
/*		int nCount;
		ar>>nCount;
		CGraph *pGraph;
		for(int i=0;i<nCount;i++)
		{
			ar>>pGraph;
			pView->m_obArray.Add(pGraph);
		}
*/
	}
//	pView->m_obArray.Serialize(ar);
	m_obArray.Serialize(ar);

}

/////////////////////////////////////////////////////////////////////////////
// CGraphicDoc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CGraphicDoc commands

void CGraphicDoc::DeleteContents() 
{
	// TODO: Add your specialized code here and/or call the base class
	int nCount;
	nCount=m_obArray.GetSize();
/*	for(int i=0;i<nCount;i++)
	{
		delete m_obArray.GetAt(i);
	//	m_obArray.RemoveAt(i);
	}
	m_obArray.RemoveAll();*/
	while(nCount--)
	{
		delete m_obArray.GetAt(nCount);
		m_obArray.RemoveAt(nCount);
	}
	
	CDocument::DeleteContents();
}

⌨️ 快捷键说明

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