home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch13 / memo / memodoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-20  |  2.6 KB  |  131 lines

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