Click here to Skip to main content
15,891,863 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.
// AtlView2.cpp : Implementation of CAtlView2

#include "stdafx.h"
#include "MfcViewLib.h"
#include "AtlView2.h"


// CAtlView2


STDMETHODIMP CAtlView2::get_Name(BSTR *pVal)
{
	// TODO: Add your implementation code here
	return m_pMfcWnd->m_pTangramObject->getAPCName(pVal);
}

STDMETHODIMP CAtlView2::put_Name(BSTR newVal)
{
	// TODO: Add your implementation code here
	return m_pMfcWnd->m_pTangramObject->putAPCName(newVal);
}

/////////////////////////////////////////////////////////////////////////////
// CShareFormView2

IMPLEMENT_DYNCREATE(CShareFormView2, CFormView)

CShareFormView2::CShareFormView2()
	: CFormView(CShareFormView2::IDD)
{
	//{{AFX_DATA_INIT(CShareFormView2)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	bHooked = false;
	m_pData = NULL;
	m_pComObj = new CComObject<CAtlView2>;
	m_pComObj->m_pMfcWnd = this;
	m_pTangramObj = g_pTangramServer->m_pCurTangramObj2;
	m_pTangramObject = g_pTangramServer->m_pCurTangramObj;
	if(m_pTangramObject)
	{
		m_pTangramObject->m_pDisp = m_pComObj;
		g_pTangramServer->m_pCurTangramObj=NULL;
	}
	else
	{
		m_pTangramObj->m_ObjClsID = CLSID_AtlView2;
		m_pTangramObj->bHooked=true;
		m_pTangramObj->m_pDisp=m_pComObj;

		g_pTangramServer->m_pCurTangramObj2=NULL;
		bHooked= true;
	}
	//m_pTangramObject = g_pTangramServer->m_pCurTangramObj;
	//g_pTangramServer->m_pCurTangramObj->m_pDisp = m_pComObj;
}

CShareFormView2::~CShareFormView2()
{
	if(!g_pTangramServer->m_bHook)
		if(m_pComObj)
		{
			if(!m_pTangramObject->m_bHooked)
				delete m_pComObj;
			//m_pComObj=NULL;
		}
	if(m_pData)
		delete m_pData;
}

void CShareFormView2::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CShareFormView2)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CShareFormView2, CFormView)
	//{{AFX_MSG_MAP(CShareFormView2)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShareFormView2 diagnostics

#ifdef _DEBUG
void CShareFormView2::AssertValid() const
{
	CFormView::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CShareFormView2 message handlers
BOOL CShareFormView2::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
	// TODO: Add your specialized code here and/or call the base class
	AfxSetResourceHandle(theApp.m_hInstance);
	return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CShareFormView2::OnInitialUpdate() 
{
	//TODO: This code navigates to a popular spot on the web.
	//Change the code to go where you'd like.
	if(m_pTangramObject&&!m_pTangramObject->bDefineRegist)
	{
		if(!m_pTangramObject->isRegist)
		{
			if(m_pTangramObject->m_DataObArray.GetSize()==0)
			{
				m_pData = new CShareFormView2DataObj();
				m_pTangramObject->m_DataObArray.SetAtGrow(0,m_pData);
			}
			else
			{
				m_pData = (CShareFormView2DataObj*)m_pTangramObject->m_DataObArray[0];
			}
		}
		else
		{
			m_pData = (CShareFormView2DataObj*)m_pTangramObject->m_DataObArray[0];
		}
		m_pTangramObject->bDefineRegist=true;
	}
	//LoadFromResource(IDR_HTML1);
}
//////////////////////////////////////////////////////////////////////
// CShareFormView2DataObj Class
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CShareFormView2DataObj, CObject, 0)

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CShareFormView2DataObj::CShareFormView2DataObj()
{

}

CShareFormView2DataObj::~CShareFormView2DataObj()
{

}

void CShareFormView2DataObj::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
	}
	else
	{
	}
}

void CShareFormView2::OnBnClickedButton1()
{
	AfxMessageBox(_T("I'm in Form 2"));
	m_pComObj->Fire_testEventX();
}

STDMETHODIMP CAtlView2::TestEvent2(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	AfxMessageBox(_T("I'm here"));
	// TODO: Add your implementation code here

	return S_OK;
}

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