// IMGPFDoc.cpp : implementation of the CIMGPFDoc class // #include "stdafx.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CIMGPFApp theApp; extern void ExitMFCApp(); ///////////////////////////////////////////////////////////////////////////// // CIMGPFDoc IMPLEMENT_DYNCREATE(CIMGPFDoc, CDocument) BEGIN_MESSAGE_MAP(CIMGPFDoc, CDocument) //{{AFX_MSG_MAP(CIMGPFDoc) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CIMGPFDoc construction/destruction CIMGPFDoc::CIMGPFDoc() { HRESULT hr; m_pRaster = NULL; hr = theApp.CreateRasterObjectLic(&m_pRaster); if (FAILED(hr)){theApp.DisplayLEADError(ERROR_INV_PARAMETER);ExitMFCApp(); return;} } CIMGPFDoc::~CIMGPFDoc() { m_pRaster->Release(); } BOOL CIMGPFDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CIMGPFDoc serialization void CIMGPFDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CIMGPFDoc diagnostics #ifdef _DEBUG void CIMGPFDoc::AssertValid() const { CDocument::AssertValid(); } void CIMGPFDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CIMGPFDoc commands BOOL CIMGPFDoc::OnOpenDocument(LPCTSTR lpszPathName) { int nRet; if(lpszPathName) { if(((CMainFrame*)theApp.m_pMainWnd)->m_pRaster->GetBitmap()) { m_pRaster->put_RefBitmap(TRUE); m_pRaster->put_Bitmap(((CMainFrame*)theApp.m_pMainWnd)->m_pRaster->GetBitmap()); m_pRaster->put_RefBitmap(FALSE); nRet = m_pRaster->GetBitmap()?0:ERROR_NO_BITMAP; } else nRet = theApp.m_pRasterIO->Load(m_pRaster, lpszPathName, 0, theApp.m_iPage, 1); if(nRet) { return(FALSE); } theApp.m_szFileName = lpszPathName; return(TRUE); } return(FALSE); }