// AnnDemoDoc.cpp : implementation of the CAnnDemoDoc class // #include "stdafx.h" #include "AnnDemo.h" #include "AnnDoc.h" #include "AnnView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CAnnDemoApp theApp; ///////////////////////////////////////////////////////////////////////////// // CAnnDemoDoc IMPLEMENT_DYNCREATE(CAnnDemoDoc, CDocument) BEGIN_MESSAGE_MAP(CAnnDemoDoc, CDocument) //{{AFX_MSG_MAP(CAnnDemoDoc) // 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() ///////////////////////////////////////////////////////////////////////////// // CAnnDemoDoc construction/destruction CAnnDemoDoc::CAnnDemoDoc() { // TODO: add one-time construction code here } CAnnDemoDoc::~CAnnDemoDoc() { } BOOL CAnnDemoDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) POSITION pos = GetFirstViewPosition(); CAnnDemoView * pView = (CAnnDemoView * ) GetNextView(pos); if(pView) pView->m_LAnnoWnd.CopyFromClipboard(pView->m_hWnd); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CAnnDemoDoc serialization void CAnnDemoDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CAnnDemoDoc diagnostics #ifdef _DEBUG void CAnnDemoDoc::AssertValid() const { CDocument::AssertValid(); } void CAnnDemoDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CAnnDemoDoc commands BOOL CAnnDemoDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; CAnnDemoApp* pApp=(CAnnDemoApp*)AfxGetApp(); L_INT nRet; // TODO: Add your specialized creation code here POSITION pos = GetFirstViewPosition(); if((pos)&&(pApp)) { FILEINFO fInfo; CAnnDemoView * pView = (CAnnDemoView *) GetNextView(pos); if(pView==NULL) return FALSE; pView->m_LAnnoWnd.SetFileName((LPTSTR)lpszPathName); LOADFILEOPTION LoadFileOption; LBaseFile::GetDefaultLoadFileOption(&LoadFileOption,sizeof(LoadFileOption)); LoadFileOption.PageNumber = pApp->m_nPageNumber; pView->m_LAnnoWnd.File()->GetInfo(&fInfo,sizeof(fInfo), 0, &LoadFileOption); if((nRet = pView->m_LAnnoWnd.Load( fInfo.BitsPerPixel, ORDER_BGRORGRAY, &LoadFileOption)) ==SUCCESS) { TCHAR szAnnFile[260]; pView->m_LAnnoWnd.GetAnnFile(szAnnFile, (LPTSTR)lpszPathName, 1, -1); pView->m_LAnnoWnd.AnnLoad(szAnnFile, &LoadFileOption); } else if(nRet == ERROR_PDF_BAD_INITIALIZATION_FILES) { if( IDYES == MessageBox ( pView->m_hWnd,TEXT("LEADTOOLS PDF plugin is not found, do you want to download the plugin now?"), TEXT("Open File"),MB_ICONEXCLAMATION | MB_YESNO)) { ShellExecute(pView->m_hWnd, TEXT("open"), TEXT("http://www.leadtools.com/ReleaseDownloads/v14/LEADTOOLSPDFRuntime.exe"), NULL, NULL, SW_SHOWNORMAL); } return FALSE; } else return FALSE; } return TRUE; } BOOL CAnnDemoDoc::OnSaveDocument(LPCTSTR lpszPathName) { // TODO: Add your specialized code here and/or call the base class //return CDocument::OnSaveDocument(lpszPathName); return FALSE; }