// BarDoc.cpp : implementation of the CBarCodeDoc class // #include "stdafx.h" #include "BarCode.h" #include "BarDoc.h" #include "BarView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CBarCodeDoc IMPLEMENT_DYNCREATE(CBarCodeDoc, CDocument) BEGIN_MESSAGE_MAP(CBarCodeDoc, CDocument) //{{AFX_MSG_MAP(CBarCodeDoc) // 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() ///////////////////////////////////////////////////////////////////////////// // CBarCodeDoc construction/destruction CBarCodeDoc::CBarCodeDoc() { } CBarCodeDoc::~CBarCodeDoc() { } BOOL CBarCodeDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; CBarCodeApp* pTheApp = (CBarCodeApp*) AfxGetApp(); CBarCodeView* pView = (CBarCodeView*)GetView(); if ((pView==NULL) || (pTheApp==NULL)) return FALSE; if (pView->m_LeadBmpWnd.SetHandle(pTheApp->m_LUserBitmap.GetHandle()) != SUCCESS) return FALSE; if (pView->m_LeadBmpWnd.HasRgn()) { pView->m_LeadBmpWnd.CancelRgn(); pView->m_LeadBmpWnd.Region()->Free(); } SetTitle(pTheApp->m_szCaption); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CBarCodeDoc serialization void CBarCodeDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CBarCodeDoc diagnostics #ifdef _DEBUG void CBarCodeDoc::AssertValid() const { CDocument::AssertValid(); } void CBarCodeDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CBarCodeDoc commands BOOL CBarCodeDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; CBarCodeApp* pTheApp = (CBarCodeApp*) AfxGetApp(); CBarCodeView* pView = (CBarCodeView*) GetView(); FILEINFO fInfo; OPENDLGPARAMS FOParm; memset(&FOParm, 0, sizeof(OPENDLGPARAMS)); memset(&fInfo, 0, sizeof(FILEINFO)); fInfo.uStructSize = sizeof(FILEINFO); pTheApp->m_LUserBitmap.DialogFile()->GetOpenParams(&FOParm, sizeof(OPENDLGPARAMS)); pView->m_LeadBmpWnd.SetFileName((L_TCHAR L_FAR *)lpszPathName); pView->m_LeadBmpWnd.File()->GetInfo(&fInfo, sizeof(FILEINFO), FILEINFO_TOTALPAGES, NULL); L_INT nRetCode = pView->m_LeadBmpWnd.Load(fInfo.BitsPerPixel, ORDER_BGRORGRAY, (FOParm.pFileData)? FOParm.pFileData[0].nPageNumber : 1); if(nRetCode!=SUCCESS) LBase::DisplayError (NULL, nRetCode); return ((nRetCode == SUCCESS) ? TRUE : FALSE); } CView* CBarCodeDoc::GetView() { POSITION pos = GetFirstViewPosition(); return GetNextView(pos); }