home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c10 / lab01 / ex05 / browserdoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.2 KB  |  100 lines

  1. // BrowserDoc.cpp : implementation of the CBrowserDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Browser.h"
  6.  
  7. #include "BrowserDoc.h"
  8. #include "MainFrm.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CBrowserDoc
  18.  
  19. IMPLEMENT_DYNCREATE(CBrowserDoc, CDocument)
  20.  
  21. BEGIN_MESSAGE_MAP(CBrowserDoc, CDocument)
  22.     //{{AFX_MSG_MAP(CBrowserDoc)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CBrowserDoc construction/destruction
  30.  
  31. CBrowserDoc::CBrowserDoc()
  32. {
  33.     // TODO: add one-time construction code here
  34.  
  35. }
  36.  
  37. CBrowserDoc::~CBrowserDoc()
  38. {
  39. }
  40.  
  41. BOOL CBrowserDoc::OnNewDocument()
  42. {
  43.     if (!CDocument::OnNewDocument())
  44.         return FALSE;
  45.  
  46.     // TODO: add reinitialization code here
  47.     // (SDI documents will reuse this document)
  48.  
  49.     return TRUE;
  50. }
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CBrowserDoc serialization
  54.  
  55. void CBrowserDoc::Serialize(CArchive& ar)
  56. {
  57.     if (ar.IsStoring())
  58.     {
  59.         // TODO: add storing code here
  60.     }
  61.     else
  62.     {
  63.         // TODO: add loading code here
  64.     }
  65. }
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CBrowserDoc diagnostics
  69.  
  70. #ifdef _DEBUG
  71. void CBrowserDoc::AssertValid() const
  72. {
  73.     CDocument::AssertValid();
  74. }
  75.  
  76. void CBrowserDoc::Dump(CDumpContext& dc) const
  77. {
  78.     CDocument::Dump(dc);
  79. }
  80. #endif //_DEBUG
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CBrowserDoc commands
  84.  
  85. CDaoDatabase * CBrowserDoc::GetDatabase( )
  86. {
  87.     return & m_daoDB;  //return a pointer to the CDaoDatabase object
  88. }
  89.  
  90. void CBrowserDoc::OnCloseDocument() 
  91. {
  92.     // TODO: Add your specialized code here and/or call the base class
  93.     
  94.     //Put the main toolbar back in place when a document closes
  95.     CMainFrame * pFrame = ( CMainFrame * ) AfxGetMainWnd( );    
  96.     pFrame->m_wndToolBar.LoadToolBar(IDR_MAINFRAME);
  97.  
  98.     CDocument::OnCloseDocument();
  99. }
  100.