// CLIPF32Doc.cpp : implementation of the CCLIPF32Doc class // #include "stdafx.h" #include "CLIPF32.h" #include "CLIPF32Doc.h" #include "CLIPF32View.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCLIPF32Doc IMPLEMENT_DYNCREATE(CCLIPF32Doc, CDocument) BEGIN_MESSAGE_MAP(CCLIPF32Doc, CDocument) //{{AFX_MSG_MAP(CCLIPF32Doc) // 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() ///////////////////////////////////////////////////////////////////////////// // CCLIPF32Doc construction/destruction CCLIPF32Doc::CCLIPF32Doc() { // TODO: add one-time construction code here } CCLIPF32Doc::~CCLIPF32Doc() { } BOOL CCLIPF32Doc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CCLIPF32Doc serialization void CCLIPF32Doc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CCLIPF32Doc diagnostics #ifdef _DEBUG void CCLIPF32Doc::AssertValid() const { CDocument::AssertValid(); } void CCLIPF32Doc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CCLIPF32Doc commands BOOL CCLIPF32Doc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; L_INT nRet = FAILURE; POSITION pos = GetFirstViewPosition(); CCLIPF32View * pView = (CCLIPF32View*) GetNextView(pos); CMainFrame * pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd(); if((pFrame!=NULL) && (pView!=NULL)) { OPENDLGPARAMS FOParm; FILEINFO fInfo; memset(&FOParm,0,sizeof(OPENDLGPARAMS)); pFrame->m_LeadDlg.GetOpenParams(&FOParm, sizeof(FOParm)); pView->m_Bitmap.SetFileName((L_TCHAR L_FAR *)lpszPathName); pView->m_Bitmap.File()->GetInfo(&fInfo, sizeof(FILEINFO)); RECT rcDest; SetRect(&rcDest,0,0,fInfo.Width,fInfo.Height); pView->m_Bitmap.SetDstRect(&rcDest); if(FOParm.pFileData != NULL) nRet = pView->m_Bitmap.Load(fInfo.BitsPerPixel,ORDER_BGRORGRAY,FOParm.pFileData[0].nPageNumber); else nRet = pView->m_Bitmap.Load(fInfo.BitsPerPixel,ORDER_BGRORGRAY,1); lstrcpy ( pView->m_szFileName, lpszPathName ); } if(nRet!=SUCCESS) LBase::DisplayError(NULL,nRet); return TRUE; }