home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / common / msdev98 / bin / ide / devgal.pkg / TEMPLATE / 22342 < prev    next >
Encoding:
Text File  |  1998-06-18  |  2.5 KB  |  109 lines

  1. // $$VAL:BaseDocCpp$$ : implementation of the $$VAL:BaseDocClass$$ class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "$$VAL:ResInclude$$"
  6.  
  7. #include "$$VAL:BaseDocHeader$$"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // $$VAL:BaseDocClass$$
  16.  
  17. IMPLEMENT_DYNCREATE($$VAL:BaseDocClass$$, CDocument)
  18.  
  19. BEGIN_MESSAGE_MAP($$VAL:BaseDocClass$$, CDocument)
  20.     //{{AFX_MSG_MAP($$VAL:BaseDocClass$$)
  21.         // NOTE - the ClassWizard will add and remove mapping macros here.
  22.         //    DO NOT EDIT what you see in these blocks of generated code!
  23.     //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // $$VAL:BaseDocClass$$ construction/destruction
  28.  
  29. $$VAL:BaseDocClass$$::$$VAL:BaseDocClass$$()
  30. {
  31.     m_hMetaFile = NULL;
  32. }
  33.  
  34. $$VAL:BaseDocClass$$::~$$VAL:BaseDocClass$$()
  35. {
  36. }
  37.  
  38. BOOL $$VAL:BaseDocClass$$::OnNewDocument()
  39. {
  40.     if (!CDocument::OnNewDocument())
  41.         return FALSE;
  42.  
  43.     // TODO: add reinitialization code here
  44.     // (SDI documents will reuse this document)
  45.  
  46.     m_hMetaFile = NULL;
  47.  
  48.     return TRUE;
  49. }
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // $$VAL:BaseDocClass$$ diagnostics
  53.  
  54. #ifdef _DEBUG
  55. void $$VAL:BaseDocClass$$::AssertValid() const
  56. {
  57.     CDocument::AssertValid();
  58. }
  59.  
  60. void $$VAL:BaseDocClass$$::Dump(CDumpContext& dc) const
  61. {
  62.     CDocument::Dump(dc);
  63. }
  64. #endif //_DEBUG
  65.  
  66. /////////////////////////////////////////////////////////////////////////////
  67. // $$VAL:BaseDocClass$$ commands
  68.  
  69. void $$VAL:BaseDocClass$$::OnCloseDocument() 
  70. {
  71.     if (m_hMetaFile != NULL)
  72.     {
  73.         VERIFY (::DeleteEnhMetaFile (m_hMetaFile));
  74.         m_hMetaFile = NULL;
  75.     }
  76.     
  77.     CDocument::OnCloseDocument();
  78. }
  79.  
  80. BOOL $$VAL:BaseDocClass$$::OnOpenDocument(LPCTSTR lpszPathName) 
  81. {
  82.     if (IsModified())
  83.         TRACE0("Warning: OnOpenDocument replaces an unsaved document.\n");
  84.  
  85.     DeleteContents();
  86.     m_hMetaFile = ::GetEnhMetaFile (lpszPathName);
  87.  
  88.     SetModifiedFlag(FALSE);     // start off with unmodified
  89.  
  90. #ifdef _MAC
  91.     WIN32_FIND_DATA fileData;
  92.     HANDLE hFind = FindFirstFile(lpszPathName, &fileData);
  93.     ASSERT(hFind != (HANDLE)-1);
  94.     VERIFY(FindClose(hFind));
  95.  
  96.     if ((fileData.wFinderFlags & kIsStationery) != 0)
  97.     {
  98.         SetModifiedFlag();
  99.         if (m_pDocTemplate != NULL)
  100.             m_pDocTemplate->SetDefaultTitle(this);
  101.  
  102.         // normally SetPathName would do this, but we aren't calling it
  103.         AfxGetApp()->AddToRecentFileList(lpszPathName);
  104.     }
  105. #endif
  106.  
  107.     return (m_hMetaFile != NULL);
  108. }
  109.