DrawCoinDoc.cpp
Upload User: zbkailong
Upload Date: 2022-05-22
Package Size: 1896k
Code Size: 2k
Category:

Graph Drawing

Development Platform:

Visual C++

  1. // DrawCoinDoc.cpp : implementation of the CDrawCoinDoc class
  2. //
  3. #include "stdafx.h"
  4. #include "DrawCoin.h"
  5. #include "DrawCoinDoc.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDrawCoinDoc
  13. IMPLEMENT_DYNCREATE(CDrawCoinDoc, CDocument)
  14. BEGIN_MESSAGE_MAP(CDrawCoinDoc, CDocument)
  15. //{{AFX_MSG_MAP(CDrawCoinDoc)
  16. ON_COMMAND(ID_COIN_ADD, OnCoinAdd)
  17. ON_COMMAND(ID_COIN_SUB, OnCoinSub)
  18. ON_UPDATE_COMMAND_UI(ID_COIN_SUB, OnUpdateCoinSub)
  19. //}}AFX_MSG_MAP
  20. END_MESSAGE_MAP()
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CDrawCoinDoc construction/destruction
  23. CDrawCoinDoc::CDrawCoinDoc()
  24. {
  25. // TODO: add one-time construction code here
  26. }
  27. CDrawCoinDoc::~CDrawCoinDoc()
  28. {
  29. }
  30. BOOL CDrawCoinDoc::OnNewDocument()
  31. {
  32. if (!CDocument::OnNewDocument())
  33. return FALSE;
  34. // TODO: add reinitialization code here
  35. // (SDI documents will reuse this document)
  36. return TRUE;
  37. }
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CDrawCoinDoc serialization
  40. void CDrawCoinDoc::Serialize(CArchive& ar)
  41. {
  42. if (ar.IsStoring())
  43. {
  44. // TODO: add storing code here
  45. }
  46. else
  47. {
  48. // TODO: add loading code here
  49. }
  50. }
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CDrawCoinDoc diagnostics
  53. #ifdef _DEBUG
  54. void CDrawCoinDoc::AssertValid() const
  55. {
  56. CDocument::AssertValid();
  57. }
  58. void CDrawCoinDoc::Dump(CDumpContext& dc) const
  59. {
  60. CDocument::Dump(dc);
  61. }
  62. #endif //_DEBUG
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CDrawCoinDoc commands
  65. void CDrawCoinDoc::DeleteContents() 
  66. {
  67. // TODO: Add your specialized code here and/or call the base class
  68. m_nCoins=0;
  69. CDocument::DeleteContents();
  70. }
  71. void CDrawCoinDoc::OnCoinAdd() 
  72. {
  73. // TODO: Add your command handler code here
  74. m_nCoins++;
  75. UpdateAllViews(NULL);
  76. }
  77. void CDrawCoinDoc::OnCoinSub() 
  78. {
  79. // TODO: Add your command handler code here
  80. if(m_nCoins>0) m_nCoins--;
  81. UpdateAllViews(NULL);
  82. }
  83. void CDrawCoinDoc::OnUpdateCoinSub(CCmdUI* pCmdUI) 
  84. {
  85. // TODO: Add your command update UI handler code here
  86. if (m_nCoins<1) pCmdUI->Enable(FALSE);
  87. else pCmdUI->Enable(TRUE);
  88. }