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

📄 vc08adoc.cpp

📁 Visual C++ 6.0编程基础与范例
💻 CPP
字号:
// vc08Doc.cpp : implementation of the CVc08Doc class
//

#include "stdafx.h"
#include "vc08a.h"

#include "vc08aDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CVc08Doc

IMPLEMENT_DYNCREATE(CVc08aDoc, CDocument)

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



/////////////////////////////////////////////////////////////////////////////
// CVc08Doc construction/destruction

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

CVc08aDoc::~CVc08aDoc()
{
}

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

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

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CVc08Doc serialization

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

}

void CVc08aDoc::SaveRec(int index,CString name,float price)
{
	if(index<0||index>m_RecArray.GetUpperBound())
		return ;
	CPrice *pPrice=new CPrice(name,price);
	m_RecArray.SetAt(index,pPrice);
	SetModifiedFlag();
};

void CVc08aDoc::AddRec(CString name,float price)
{
	CPrice *pPrice=new CPrice(name,price);
	m_RecArray.Add(pPrice);
	SetModifiedFlag();
};

void CVc08aDoc::DelRec(int index)
{
	if(index<0||index>m_RecArray.GetUpperBound())
		return ;
	m_RecArray.RemoveAt(index,1);
	SetModifiedFlag();
}


CPrice * CVc08aDoc::GetRec(int index)
{
	if(index<0||index>m_RecArray.GetUpperBound())
		return 0;
	return(CPrice *)m_RecArray.GetAt(index);
};


int CVc08aDoc::GetTotalRec()
{
	return m_RecArray.GetSize();
};

void CVc08aDoc::DeleteContents()
{
	int index;
	index=m_RecArray.GetSize();
	while(index--)
		delete m_RecArray.GetAt(index);
	m_RecArray.RemoveAll();
}

/////////////////////////////////////////////////////////////////////////////
// CVc08Doc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CVc08Doc commands
IMPLEMENT_SERIAL(CPrice,CObject,1)

CPrice::CPrice(CString name,float price)
{
	m_Name=name;
	m_Price=price;
};

void CPrice::Serialize(CArchive&ar)
{
	if(ar.IsStoring()){
		ar << m_Name << m_Price;
	}
	else{
		ar >> m_Name >> m_Price;
	}
}

⌨️ 快捷键说明

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