home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c07 / lab02 / ex02 / diffdoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  1.9 KB  |  100 lines

  1. // diffDoc.cpp : implementation of the CDiffDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "diff.h"
  6.  
  7. #include "diffDoc.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CDiffDoc
  16.  
  17. IMPLEMENT_DYNCREATE(CDiffDoc, CRichEditDoc)
  18.  
  19. BEGIN_MESSAGE_MAP(CDiffDoc, CRichEditDoc)
  20.     //{{AFX_MSG_MAP(CDiffDoc)
  21.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  22.     //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CDiffDoc construction/destruction
  27.  
  28. CDiffDoc::CDiffDoc()
  29. {
  30.     // TODO: add one-time construction code here
  31.  
  32. }
  33.  
  34. CDiffDoc::~CDiffDoc()
  35. {
  36. }
  37.  
  38. CRichEditCntrItem* CDiffDoc::CreateClientItem(REOBJECT* preo) const
  39. {
  40.         return new CRichEditCntrItem();
  41. }
  42.  
  43. BOOL CDiffDoc::OnNewDocument()
  44. {
  45.     if (!CRichEditDoc::OnNewDocument())
  46.         return FALSE;
  47.  
  48.     // TODO: add reinitialization code here
  49.     // (SDI documents will reuse this document)
  50.  
  51.     return TRUE;
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CDiffDoc serialization
  56.  
  57. void CDiffDoc::Serialize(CArchive& ar)
  58. {
  59.     if (ar.IsStoring())
  60.     {
  61.         // TODO: add storing code here
  62.     }
  63.     else
  64.     {
  65.         // TODO: add loading code here
  66.     }
  67. }
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CDiffDoc diagnostics
  71.  
  72. #ifdef _DEBUG
  73. void CDiffDoc::AssertValid() const
  74. {
  75.     CRichEditDoc::AssertValid();
  76. }
  77.  
  78. void CDiffDoc::Dump(CDumpContext& dc) const
  79. {
  80.     CRichEditDoc::Dump(dc);
  81. }
  82. #endif //_DEBUG
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CDiffDoc commands
  86.  
  87. void CDiffDoc::OnFileOpen() 
  88. {
  89.     static char BASED_CODE szFilter[] =
  90.             "All Files (*.*)|*.*|C++ Files (*.cpp, *.h)" \
  91.             "|*.cpp;*.h||";
  92.  
  93.     CFileDialog dlg(TRUE,NULL,NULL,NULL,szFilter);
  94.  
  95.     if(dlg.DoModal() == IDOK)
  96.     {
  97.         m_File1 = m_File2 = dlg.GetPathName();
  98.     }
  99. }
  100.