|
#include "StdAfx.h"
#include "[!output PROJECT_NAME]DocObject.h"
#include "[!output PROJECT_NAME]Doc.h"
#include "ManagedObj.h"
[!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::[!output PROJECT_NAME]DocObject(void)
{
theApp.m_pManagedCnnObj = this;
m_pDoc = (C[!output PROJECT_NAME]Doc*)theApp.m_pCurDoc;
m_pMainCtrl = new MainCtrl();
set_PrjItem(S"MainCtrl", m_pMainCtrl);
}
[!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::~[!output PROJECT_NAME]DocObject(void)
{
}
void [!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::OnNewDocument()
{
}
void [!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::OnOpenDocument()
{
}
void [!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::Connect(Object* pCtrlObj, String* strObjName)
{
//insert object into object dictionary,thus other component can
//using this object through the property "PrjItem" of a document object:
set_PrjItem(strObjName, pCtrlObj);
//you can convert pCtrlObj to some proper object like this:
//somenamespace::someobj* pNewCtrlObj = __try_cast<somenamespace::someobj*>(pCtrlObj);
//if you want to hook event for this object,you can do like this:
//if(strObjName == S"somename")
//{
// pNewCtrlObj->add_SomeEvet(new System::EventHandler(this,OnSomeFunctionInThisObject));
//}
//if there exists an external document object, we pass pCtrlObj to this external document object,
//the provider of external document object can get pCtrlObj in the following manner:
if(m_pExternalDocObj)
{
Type* t = m_pExternalDocObj->GetType();
MethodInfo* mi = t->GetMethod(S"Connect");
Object* p[] = new Object*[2];
p[0] = pCtrlObj;
p[1] = strObjName;
mi->Invoke(m_pExternalDocObj,p);
}
}
//Sample Properties implement:
String* [!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::get_Caption()
{
if(m_pDoc)
{
String* strCaption = m_pDoc->GetTitle();
return strCaption;
}
return S"";
}
void [!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::set_Caption(String* newCaption)
{
if(m_pDoc)
{
CString strCaption = theApp.StringToCStr(newCaption);
m_pDoc->SetTitle(LPCTSTR(strCaption));
}
}
void [!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::set_PrjItem(String* strIndex, Object* value)
{
CString m_strDocIndex = theApp.StringToCStr(strIndex);
m_strDocIndex.MakeLower();
CManagedObj* m_pManagedObj = NULL;
if(!m_pDoc->m_PrjItemDictionary.Lookup(LPCTSTR(m_strDocIndex),(CObject*&)m_pManagedObj))
{
m_pManagedObj = new CManagedObj();
m_pManagedObj -> m_pManagedObj = value;
m_pDoc->m_PrjItemDictionary.SetAt(m_strDocIndex, m_pManagedObj);
}
}
Object* [!output PROJECT_NAME]::[!output PROJECT_NAME]DocObject::get_PrjItem(String* strIndex)
{
CString m_strDocIndex = theApp.StringToCStr(strIndex);
m_strDocIndex.MakeLower();
CManagedObj* m_pManagedObj = NULL;
if(m_pDoc->m_PrjItemDictionary.Lookup(LPCTSTR(m_strDocIndex),(CObject*&)m_pManagedObj))
return m_pManagedObj->m_pManagedObj;
return NULL;
}
|
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.
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