Click here to Skip to main content
15,893,337 members
Articles / Desktop Programming / MFC

Develop MFC Doc/View Application Which Supports Any Number Document Template

Rate me:
Please Sign up or sign in to vote.
1.57/5 (3 votes)
2 Jun 20052 min read 36.5K   1.7K   26  
This article provides an introduction to TangramLittle, a C++ Framework for MFC and the .NET Framework. Knowledge in MFC and the .NET Framework is assumed.
// [!output PROJECT_NAME]Doc.h : interface of the C[!output PROJECT_NAME]Doc class
//
#pragma once
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Windows::Forms;

#include "[!output PROJECT_NAME]DocObject.h"
using namespace [!output PROJECT_NAME];

class C[!output PROJECT_NAME]Doc : public COleDocument
{
protected: // create from serialization only
	C[!output PROJECT_NAME]Doc();
	DECLARE_DYNCREATE(C[!output PROJECT_NAME]Doc)

// Attributes
public:
	CDocumentInfo m_DocumentInfo;
	CMapStringToOb	m_PrjItemDictionary;
	/*About Document Object(DocObject) 
	In general, a document based application usually supply an object (COM based or .NET based) 
	for each document in order to make document customize easily.If such an object exists in a document,
	this document can be automation by other system just like microsoft office do. You can create such 
	kind of object by other lanageuage such as VB.Net, VC# etc,and use it in your MFC based application, 
	or you can derive it from an exists object, here we just need to konw object class ID. 
	You can load object ID from a exists file(say an XML file) or from Registry.
	In general, your can use an DocObject to Initial a document's function.
	For example, use this id, your can give each document a VB.Net project or a VC# project which
	implement a document object.In microsoft office, microsoft give each office document a VBA 
	Project, you can realize a similiar fashion in your application by supply an object for each document.
	*/
	CString			m_strDocObjID;
	//��ż�ĵ���������ͨ��.NET�������MFC�ĵ�
	gcroot<[!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject*>	m_p[!output PROJECT_NAME]DocObj;
	
	//About External Document Object:
	//Your External Document Object must have a property - "Document" which hold a pointer
	//to the Document object created above. By using the property, an external component can hook the 
	//document object's events, call its methods , modify its properties etc. 
	//In general the Document Object may reference the External Document Object(and vice versa).
	//When document object and external document object establish a reference to eachother,
	//they can interact on each other more effectively.
	CString			m_strExternalDocObjID;
	//��չ�ĵ���������ʵ�ֶ��ο���
	gcroot<Object*>	m_pExternalDocObj;
// Operations
public:

// Overrides
public:
	virtual BOOL OnNewDocument();
	virtual void OnCloseDocument();
	virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
	virtual void Serialize(CArchive& ar);

// Implementation
public:
	virtual ~C[!output PROJECT_NAME]Doc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	void InitialDocument();
// Generated message map functions
protected:
	DECLARE_MESSAGE_MAP()
};


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here



Comments and Discussions