home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch19 / pad / paddoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-24  |  2.4 KB  |  120 lines

  1. // paddoc.cpp : implementation of the CPadDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "pad.h"
  6.  
  7. #include "paddoc.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char BASED_CODE THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CPadDoc
  16.  
  17. IMPLEMENT_DYNCREATE(CPadDoc, CDocument)
  18.  
  19. BEGIN_MESSAGE_MAP(CPadDoc, CDocument)
  20.     //{{AFX_MSG_MAP(CPadDoc)
  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. // CPadDoc construction/destruction
  28.  
  29. CPadDoc::CPadDoc()
  30. {
  31.     // TODO: add one-time construction code here
  32. }
  33.  
  34. CPadDoc::~CPadDoc()
  35. {
  36. }
  37.  
  38. BOOL CPadDoc::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.  
  47.     //////////////////////
  48.     // MY CODE STARTS HERE
  49.     //////////////////////
  50.  
  51.     // Make the new document blank.
  52.     m_Subject = "";
  53.     m_Notes   = "";
  54.  
  55.     ////////////////////
  56.     // MY CODE ENDS HERE
  57.     ////////////////////
  58.  
  59.  
  60.     return TRUE;
  61. }
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CPadDoc serialization
  65.  
  66. void CPadDoc::Serialize(CArchive& ar)
  67. {
  68.     if (ar.IsStoring())
  69.     {
  70.         // TODO: add storing code here
  71.  
  72.         //////////////////////
  73.         // MY CODE STARTS HERE
  74.         //////////////////////
  75.  
  76.         // Write to the file.
  77.         ar << m_Subject << m_Notes;
  78.  
  79.         ////////////////////
  80.         // MY CODE ENDS HERE
  81.         ////////////////////
  82.  
  83.     }
  84.     else
  85.     {
  86.         // TODO: add loading code here
  87.  
  88.  
  89.         //////////////////////
  90.         // MY CODE STARTS HERE
  91.         //////////////////////
  92.  
  93.         // Read from the file.
  94.         ar >> m_Subject >> m_Notes;
  95.  
  96.         ////////////////////
  97.         // MY CODE ENDS HERE
  98.         ////////////////////
  99.  
  100.     }
  101. }
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CPadDoc diagnostics
  105.  
  106. #ifdef _DEBUG
  107. void CPadDoc::AssertValid() const
  108. {
  109.     CDocument::AssertValid();
  110. }
  111.  
  112. void CPadDoc::Dump(CDumpContext& dc) const
  113. {
  114.     CDocument::Dump(dc);
  115. }
  116. #endif //_DEBUG
  117.  
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CPadDoc commands
  120.