📄 myextdatamodel.cpp
字号:
// MyExtDataModel.cpp: implementation of the CMyExtDataModel class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyExtDataModel.h"
#include "CustomTool.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyExtDataModel construction/destruction
IMPLEMENT_SERIAL(CMyExtDataModel, CFODataModel, 0)
CMyExtDataModel::CMyExtDataModel()
{
//FOTO:Add you code here.
DoInitData();
}
CMyExtDataModel::CMyExtDataModel(const CMyExtDataModel& /*source*/)
{
}
CMyExtDataModel::~CMyExtDataModel()
{
//FOTO:Add you code here.
}
void CMyExtDataModel::DoInitData()
{
SetFormMode(TRUE);
SetFormFreeSize(TRUE);
CFODataModel::DoInitData();
SetPageBkColor(RGB(255,255,255));
//FOTO:Add you code here.
}
void CMyExtDataModel::NotifyObserver(LPARAM lHint, CObject*pHint)
{
CFODataModel::NotifyObserver(lHint,pHint);
//FOTO:Add you code here.
}
void CMyExtDataModel::UpdateTitle()
{
CFODataModel::UpdateTitle();
// if(m_pOwner == NULL)
// {
// return;
// }
//
// if(m_pOwner->GetSafeHwnd() != NULL)
// {
// if(m_pOwner ->IsKindOf(RUNTIME_CLASS(CFODrawView)))
// {
// CFODrawView *pView = (CFODrawView *) m_pOwner;
// CDocument *m_pDocument = (CDocument *)pView->GetDocument();
// if(m_pDocument != NULL)
// {
// if (m_strTitleOrg.IsEmpty() && !m_pDocument->GetTitle().IsEmpty())
// m_strTitleOrg = m_pDocument->GetTitle();
//
// if (!m_strTitleOrg.IsEmpty())
// {
// TCHAR szStr[256+_MAX_PATH];
// _tcscpy(szStr, m_strTitleOrg);
// if (IsDirty())
// {
// if(m_strTitleOrg.Find(_T("*"))<0)
// {
// lstrcat(szStr, _T(" *"));
// }
// }
// if (m_pDocument->GetTitle() != szStr)
// {
// m_pDocument->SetTitle(szStr);
// m_pDocument->UpdateFrameCounts();
// }
// }
// }
// }
// }
}
void CMyExtDataModel::DoActionChange(const CFOBaseAction* pAction)
{
CFODataModel::DoActionChange(pAction);
// FODO:Add your own specify code here.
}
CString CMyExtDataModel::GetUniqueName(UINT nType)
{
// Sample:
/*CString strReturn;
strReturn = "nLine";
if(nType == MY_LINE_TYPE)
{
return strReturn;
}
else
{
return CFODataModel::GetUniqueName(nType);
}*/
return CFODataModel::GetUniqueName(nType);
}
CString CMyExtDataModel::GetUniqueCaption(UINT nType)
{
// Sample:
/* CString strReturn;
strReturn = "Line";
if(nType == MY_LINE_TYPE)
{
return strReturn;
}
else
{
return CFODataModel::GetUniqueCaption(nType);
}*/
return CFODataModel::GetUniqueCaption(nType);
}
CFODrawShape *CMyExtDataModel::DoCreateShapeByType(UINT m_drawshape,
CRect &rcCreate,
CString strFileName,
CFOToolBoxItem *pCurItem)
{
CFODrawShape *pReturn = CFODataModel::DoCreateShapeByType(m_drawshape,
rcCreate,
strFileName,
pCurItem);
// FODO: Add your own specify code here.
return pReturn;
}
CFOCompositeShape *CMyExtDataModel::DoCreateCompositeShapeByType(UINT m_drawshape,
CRect &rcCreate,
CArray<FOPORTVALUE,FOPORTVALUE> *arInitPorts,
CString strFileName,
UINT nResID,
CFOToolBoxItem *pCurItem)
{
CFOCompositeShape *pReturn = CFODataModel::DoCreateCompositeShapeByType(m_drawshape,
rcCreate,
arInitPorts,
strFileName,
nResID,
pCurItem);
// FODO: Add your own specify code here.
return pReturn;
}
void CMyExtDataModel::SetModifiedFlag(BOOL b)
{
CFODataModel::SetModifiedFlag(b);
//FOTO:Add you code here.
}
BOOL CMyExtDataModel::IsModified()
{
//FOTO:Add you code here.
return CFODataModel::IsModified();
}
void CMyExtDataModel::Serialize(CArchive& ar)
{
CFODataModel::Serialize(ar);
if(ar.IsStoring())
{
//FOTO:Add you code here.
}
else
{
//FOTO:Add you code here.
}
}
/////////////////////////////////////////////////////////////////////////////
// CPrintBaseJob serialization
CFile* CMyExtDataModel::GetFile(LPCTSTR lpszFileName, UINT nOpenFlags,
CFileException* pError)
{
CMirrorFile* pFile = new CMirrorFile;
ASSERT(pFile != NULL);
if (!pFile->Open(lpszFileName, nOpenFlags, pError))
{
delete pFile;
pFile = NULL;
}
return pFile;
}
void CMyExtDataModel::ReleaseFile(CFile* pFile, BOOL bAbort)
{
ASSERT_KINDOF(CFile, pFile);
if (bAbort)
pFile->Abort(); // will not throw an exception
else
pFile->Close();
delete pFile;
}
BOOL CMyExtDataModel::OpenDocument(LPCTSTR lpszPathName)
{
CFileException fe;
CFile* pFile = GetFile(lpszPathName,
CFile::modeRead|CFile::shareDenyWrite, &fe);
if (pFile == NULL)
{
return FALSE;
}
strCurOpenFormFile = CString(lpszPathName);
CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete);
loadArchive.m_bForceFlat = FALSE;
TRY
{
CWaitCursor wait;
if (pFile->GetLength() != 0)
Serialize(loadArchive); // load me
loadArchive.Close();
ReleaseFile(pFile, FALSE);
}
CATCH_ALL(e)
{
ReleaseFile(pFile, TRUE);
return FALSE;
}
END_CATCH_ALL
return TRUE;
}
BOOL CMyExtDataModel::SaveDocument(LPCTSTR lpszPathName)
{
CFileException fe;
CFile* pFile = NULL;
pFile = GetFile(lpszPathName, CFile::modeCreate |
CFile::modeReadWrite | CFile::shareExclusive, &fe);
if (pFile == NULL)
{
return FALSE;
}
strCurOpenFormFile = CString(lpszPathName);
CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
saveArchive.m_bForceFlat = FALSE;
TRY
{
CWaitCursor wait;
Serialize(saveArchive); // save me
saveArchive.Close();
ReleaseFile(pFile, FALSE);
}
CATCH_ALL(e)
{
ReleaseFile(pFile, TRUE);
return FALSE;
}
END_CATCH_ALL
return TRUE; // success
}
void CMyExtDataModel::OnDrawShape(CDC *pDC,const CRect &rcView)
{
CFODataModel::OnDrawShape(pDC,rcView);
//FOTO:Add you code here.
}
void CMyExtDataModel::OnDrawBack(CDC *pDC)
{
CFODataModel::OnDrawBack(pDC);
//FOTO:Add you code here.
}
/////////////////////////////////////////////////////////////////////////////
// CMyExtDataModel diagnostics
#ifdef _DEBUG
void CMyExtDataModel::AssertValid() const
{
CFODataModel::AssertValid();
}
void CMyExtDataModel::Dump(CDumpContext& dc) const
{
CFODataModel::Dump(dc);
}
#endif //_DEBUG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -