Click here to Skip to main content
15,885,835 members
Articles / Desktop Programming / ATL

Create a Universal Document Template which supports Dynamic Frame Window Layout

Rate me:
Please Sign up or sign in to vote.
3.00/5 (8 votes)
14 Dec 20024 min read 49.3K   668   24  
Introduce a programming technology to design a very complex, rich document type.
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This source code is a part of Tangram library.
// You may use, compile or redistribute it as part of your application 
// for free. You cannot redistribute it as a part of a software development 
// library without the agreement of the author. If the sources are 
// distributed along with the application, you should leave the original 
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES on your own risk.
// 
// For the latest updates to this library, check site:
// http://www.tangramdev.com
// 
// sunhui
//*******************************************************************************
#pragma once

// ObjExtManager.h : header file
//

#include "stdafx.h"

HRESULT ProcessDlgMsg(BOOL bProcess, HWND hWnd);
HRESULT RegDesignerFilter(IMessageFilter* pDesignerFilter, IDispatch* pAssDisp,DWORD& rofferApplicationObjectCookie);
void InitLib();
void GetClsIDString(CString& strClsID);
HRESULT GetNewGUID(CString& pRetval);
void TangramSerializeGUID(CArchive& ar, GUID& guid);

void ConnectClsInfo();
class CTGObject;
class CTangramWindowObj;
class CTangramManager;
class CDesignerManager;
class CTangramServerObj;
class CDocCntrItem;
class CTangramObject;
class CTangramObj;

CTangramServerObj* GetTangramServer();

///////////////////////////////////////////
class CConnectObj : public CObject  
{
	DECLARE_DYNCREATE(CConnectObj)
public:
	virtual void Connect(BOOL bLoading);
	CConnectObj();
	virtual ~CConnectObj();
	CRuntimeClass* m_pViewClass;
	CWnd* m_pParentWnd;
	CTangramWindowObj* m_pTangramWindowObj;
	CTangramManager* m_pObjExtManager;
	CObject* m_pTangramObj;
	CObject* m_pMfcObj;
	IDispatch* m_pAppDisp;
	IDispatch* m_pDocDisp;
	IDispatch* m_pObjDisp;
	UINT nChildID;
	CCreateContext* m_pContext;
	CObArray m_DataObArray;

};

/////////////////////////////////////////

class CTangramManager 
{
// Attributes
public:
	CTangramManager(CFrameWnd *pFrameWnd, CRuntimeClass* pFrameClass, CRuntimeClass* pDockBarClass = NULL, CString strServerID = _T("TangramAppServer.Documents"),IDispatch*pAppDisp=NULL,CRuntimeClass* pDesignClsInfo=NULL, BOOL bMDI=TRUE,BOOL bMDITab = FALSE);           
	virtual ~CTangramManager();
	CTangramServerObj* m_pTGObj;
	BOOL m_bMdi;
	BOOL m_bMdiTab;
	CWinApp* m_pApp;
	CRuntimeClass* m_pLibClass;
	CComPtr<IDispatch> m_pTangramServerDisp;
// Operations
public:
	void AddMfcObject(CRuntimeClass* pMfcObjInfo, CRuntimeClass* pMfcConnectObjInfo=NULL, CString strHeader = _T(""));
	BOOL CloseDocuments();
	BOOL SetBitmap(HBITMAP hBitmap);

	void NewDocument(CString strDocType);

// Implementation
protected:

private:
	CWnd* m_pMDITabClientWnd;
};

/////////////////////////////////////////////////////////////////////////////
class CTangramOleClientItem;

class CTangramWindowObj  
{
public:
	CTangramWindowObj();
	virtual ~CTangramWindowObj();

	virtual void SetTangramObj(CObject* m_pObj);
	virtual void IniContainer(BOOL isLoading);
	virtual void ShowPropertyPage();
	virtual HBITMAP GetBitmap();
	int QueryProgIDType(CString strClsID);

	CTangramObject* m_pTangramObject;
	CTangramObj* m_pTangramObj;
	CRuntimeClass* m_pBorderClass;
	CWnd* m_pBorderWnd;
	CDocCntrItem* m_pOleItem;
	IDispatch* m_pWindowDisp;
};

class CTangramDocObj  
{
public:
	CTangramDocObj();
	virtual ~CTangramDocObj();

	virtual void ConnectExternalLib(CString strCnn)=0;
	virtual HPALETTE GetPaletteFromDoc(){return NULL;};
	virtual HBITMAP GetBitmapFromDoc(){return NULL;};

	CString m_strCaption;
	IDispatch* m_pTangramDocDisp;
};

class CTangramDoc;
class CTangramDocuments 
{
public:
	CTangramDocuments();
	virtual ~CTangramDocuments();

	virtual int GetDocsCount();
	virtual void ClearCollection()=0;
	virtual void AddToCollection(CTangramDoc *pDoc)=0;
	virtual void RemoveFromCollection(CTangramDoc *pDoc)=0;

	CPtrList m_listDocs;
};

extern CTangramServerObj* g_pTangramServer;

class CTangramFrameObj  
{
public:
	CTangramFrameObj();
	virtual ~CTangramFrameObj();

	void Create(CFrameWnd* pFrame);
	virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
	virtual void OnActivate(BOOL bActivate);
	virtual void OnDestroy();

	BOOL m_bActiveFrame;
	CFrameWnd* m_pFrameWnd;
	CTangramDoc* m_pDoc;
	CTangramFrameObj* m_pOwner;
};

////////////////////////////////////////////////////
// CSystemManagerFrameWnd ���
class CSystemManagerFrameWnd : public CFrameWnd
{
	DECLARE_DYNCREATE(CSystemManagerFrameWnd)
protected:
	CSystemManagerFrameWnd();           // ��̬������ʹ�õ��ܱ����Ĺ��캯��
	virtual ~CSystemManagerFrameWnd();
public:
//////////////////$tangramapp$////////////////////////////
	CTangramFrameObj m_TangramFrameObj;
//////////////////$tangramapp end$////////////////////////////

protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
	afx_msg void OnDestroy();
};

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


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions