home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / mdidocvw / hellodoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.3 KB  |  116 lines

  1. // HelloDoc.cpp : implementation of the CHelloDoc class
  2. //
  3.  
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1998 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14. #include "stdafx.h"
  15. #include "MDI.h"
  16.  
  17. #include "HelloDoc.h"
  18.  
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CHelloDoc
  27.  
  28. IMPLEMENT_DYNCREATE(CHelloDoc, CDocument)
  29.  
  30. BEGIN_MESSAGE_MAP(CHelloDoc, CDocument)
  31.     //{{AFX_MSG_MAP(CHelloDoc)
  32.     //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CHelloDoc construction/destruction
  37.  
  38. CHelloDoc::CHelloDoc()
  39. {
  40. }
  41.  
  42. CHelloDoc::~CHelloDoc()
  43. {
  44. }
  45.  
  46. BOOL CHelloDoc::OnNewDocument()
  47. {
  48.     if (!CDocument::OnNewDocument())
  49.         return FALSE;
  50.  
  51. // initialization of document's data
  52.  
  53.     m_clrText = RGB(0, 0, 255);
  54.     m_str = _T("Hello, world!");
  55.  
  56. // initialization of button states for each color
  57.  
  58.     m_bBlue = 1;
  59.     m_bBlack = 0;
  60.     m_bGreen = 0;
  61.     m_bRed = 0;
  62.     m_bWhite = 0;
  63.     m_bCustom = 0;
  64.  
  65.     return TRUE;
  66. }
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CHelloDoc serialization
  70.  
  71. void CHelloDoc::Serialize(CArchive& ar)
  72. {
  73.     if (ar.IsStoring())
  74.     {
  75.     }
  76.     else
  77.     {
  78.     }
  79. }
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CHelloDoc diagnostics
  83.  
  84. #ifdef _DEBUG
  85. void CHelloDoc::AssertValid() const
  86. {
  87.     CDocument::AssertValid();
  88. }
  89.  
  90. void CHelloDoc::Dump(CDumpContext& dc) const
  91. {
  92.     CDocument::Dump(dc);
  93. }
  94. #endif //_DEBUG
  95.  
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CHelloDoc commands
  98.  
  99. void CHelloDoc::SetStrColor(COLORREF clr)
  100. {
  101.     m_clrText = clr;
  102.     UpdateAllViews(NULL);
  103. }
  104.  
  105. void CHelloDoc::SetCustomStrColor(COLORREF clr)
  106. {
  107.     m_clrText = clr;
  108.     UpdateAllViews(NULL);
  109. }
  110.  
  111. void CHelloDoc::ClearAllColors()
  112. {
  113.     m_bBlack = m_bBlue = m_bRed = 0;
  114.     m_bWhite = m_bGreen = 0;
  115. }
  116.