home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch14 / phn / phndoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-21  |  2.8 KB  |  147 lines

  1. // phndoc.cpp : implementation of the CPhnDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "phn.h"
  6.  
  7. //////////////////////
  8. // MY CODE STARTS HERE
  9. //////////////////////
  10.  
  11. #include "phone.h"
  12.  
  13. ////////////////////
  14. // MY CODE ENDS HERE
  15. ////////////////////
  16.  
  17.  
  18. #include "phndoc.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CPhnDoc
  27.  
  28. IMPLEMENT_DYNCREATE(CPhnDoc, CDocument)
  29.  
  30. BEGIN_MESSAGE_MAP(CPhnDoc, CDocument)
  31.     //{{AFX_MSG_MAP(CPhnDoc)
  32.         // NOTE - the ClassWizard will add and remove mapping macros here.
  33.         //    DO NOT EDIT what you see in these blocks of generated code!
  34.     //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CPhnDoc construction/destruction
  39.  
  40. CPhnDoc::CPhnDoc()
  41. {
  42.     // TODO: add one-time construction code here
  43. }
  44.  
  45. CPhnDoc::~CPhnDoc()
  46. {
  47. }
  48.  
  49. BOOL CPhnDoc::OnNewDocument()
  50. {
  51.     if (!CDocument::OnNewDocument())
  52.         return FALSE;
  53.  
  54.     // TODO: add reinitialization code here
  55.     // (SDI documents will reuse this document)
  56.  
  57.  
  58.     //////////////////////
  59.     // MY CODE STARTS HERE
  60.     //////////////////////
  61.  
  62.     // Create an object of class CPhone.
  63.     CPhone* pPhone  = new CPhone();
  64.     pPhone->m_Name  = "";
  65.     pPhone->m_Phone = "";
  66.  
  67.     // Add the new object to the m_PhoneList list.
  68.     m_PhoneList.AddHead(pPhone);
  69.  
  70.     ////////////////////
  71.     // MY CODE ENDS HERE
  72.     ////////////////////
  73.  
  74.  
  75.  
  76.     return TRUE;
  77. }
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CPhnDoc serialization
  81.  
  82. void CPhnDoc::Serialize(CArchive& ar)
  83. {
  84.     if (ar.IsStoring())
  85.     {
  86.         // TODO: add storing code here
  87.     }
  88.     else
  89.     {
  90.         // TODO: add loading code here
  91.         
  92.     }
  93.  
  94.     //////////////////////
  95.     // MY CODE STARTS HERE
  96.     //////////////////////
  97.     
  98.     m_PhoneList.Serialize(ar);
  99.     
  100.     ////////////////////
  101.     // MY CODE ENDS HERE
  102.     ////////////////////
  103.  
  104.  
  105.  
  106. }
  107.  
  108. /////////////////////////////////////////////////////////////////////////////
  109. // CPhnDoc diagnostics
  110.  
  111. #ifdef _DEBUG
  112. void CPhnDoc::AssertValid() const
  113. {
  114.     CDocument::AssertValid();
  115. }
  116.  
  117. void CPhnDoc::Dump(CDumpContext& dc) const
  118. {
  119.     CDocument::Dump(dc);
  120. }
  121. #endif //_DEBUG
  122.  
  123. /////////////////////////////////////////////////////////////////////////////
  124. // CPhnDoc commands
  125.  
  126.  
  127. //////////////////////
  128. // MY CODE STARTS HERE
  129. //////////////////////
  130.  
  131. void CPhnDoc::DeleteContents()
  132. {
  133.  
  134.    // Remove all the items in the list and free the
  135.    // memory occupied by the listed objects.
  136.    while ( !m_PhoneList.IsEmpty() )
  137.          {
  138.          delete m_PhoneList.RemoveHead();
  139.          }
  140. }
  141.  
  142. ////////////////////
  143. // MY CODE ENDS HERE
  144. ////////////////////
  145.  
  146.  
  147.