home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch05 / var / varview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-19  |  3.6 KB  |  170 lines

  1. // varview.cpp : implementation of the CVarView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "var.h"
  6.  
  7. #include "vardoc.h"
  8. #include "varview.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CVarView
  17.  
  18. IMPLEMENT_DYNCREATE(CVarView, CView)
  19.  
  20. BEGIN_MESSAGE_MAP(CVarView, CView)
  21.     //{{AFX_MSG_MAP(CVarView)
  22.     ON_COMMAND(ID_FILE_CURRENTVALUE, OnFileCurrentvalue)
  23.     ON_COMMAND(ID_FILE_TWO, OnFileTwo)
  24.     ON_COMMAND(ID_FILE_ONE, OnFileOne)
  25.     ON_COMMAND(ID_FILE_THREE, OnFileThree)
  26.     //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CVarView construction/destruction
  31.  
  32. CVarView::CVarView()
  33. {
  34.     // TODO: add construction code here
  35. }
  36.  
  37. CVarView::~CVarView()
  38. {
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CVarView drawing
  43.  
  44. void CVarView::OnDraw(CDC* pDC)
  45. {
  46.     CVarDoc* pDoc = GetDocument();
  47.     ASSERT_VALID(pDoc);
  48.  
  49.     // TODO: add draw code for native data here
  50. }
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CVarView diagnostics
  54.  
  55. #ifdef _DEBUG
  56. void CVarView::AssertValid() const
  57. {
  58.     CView::AssertValid();
  59. }
  60.  
  61. void CVarView::Dump(CDumpContext& dc) const
  62. {
  63.     CView::Dump(dc);
  64. }
  65.  
  66. CVarDoc* CVarView::GetDocument() // non-debug version is inline
  67. {
  68.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVarDoc)));
  69.     return (CVarDoc*)m_pDocument;
  70. }
  71. #endif //_DEBUG
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CVarView message handlers
  75.  
  76. void CVarView::OnFileCurrentvalue()
  77. {
  78.     // TODO: Add your command handler code here
  79.  
  80.     //////////////////////
  81.     // MY CODE STARTS HERE
  82.     //////////////////////
  83.  
  84.     // Get a pointer to the document class.
  85.     CVarDoc* pDoc = GetDocument();
  86.  
  87.     // Display the current value of m_MyVar
  88.     MessageBox("Current value of m_MyVar is: " 
  89.                      + pDoc->m_MyVar);
  90.  
  91. ////////////////////
  92. // MY CODE ENDS HERE
  93. ////////////////////
  94.  
  95.     
  96. }
  97.  
  98. void CVarView::OnFileTwo()
  99. {
  100.     // TODO: Add your command handler code here
  101.     
  102.      //////////////////////
  103.      // MY CODE STARTS HERE
  104.      //////////////////////
  105.  
  106.      // Get a pointer to the document class.
  107.      CVarDoc* pDoc = GetDocument();
  108.  
  109.      // Change the value of m_MyVar to "Two".
  110.      pDoc->m_MyVar = "Two";
  111.  
  112.      // Tell the user that m_MyVar was changed to "One".
  113.      MessageBox("m_MyVar is now: " + pDoc->m_MyVar);
  114.  
  115.      ////////////////////
  116.      // MY CODE ENDS HERE
  117.      ////////////////////
  118.     
  119.     
  120. }
  121.  
  122. void CVarView::OnFileOne()
  123. {
  124.     // TODO: Add your command handler code here
  125.  
  126.  
  127.      //////////////////////
  128.      // MY CODE STARTS HERE
  129.      //////////////////////
  130.  
  131.      // Get a pointer to the document class.
  132.      CVarDoc* pDoc = GetDocument();
  133.  
  134.      // Change the value of m_MyVar to "One".
  135.      pDoc->m_MyVar = "One";
  136.  
  137.      // Tell the user that m_MyVar was changed to "One".
  138.      MessageBox("m_MyVar is now: " + pDoc->m_MyVar);
  139.  
  140.      ////////////////////
  141.      // MY CODE ENDS HERE
  142.      ////////////////////
  143.  
  144.     
  145. }
  146.  
  147. void CVarView::OnFileThree()
  148. {
  149.     // TODO: Add your command handler code here
  150.  
  151.      //////////////////////
  152.      // MY CODE STARTS HERE
  153.      //////////////////////
  154.  
  155.      // Get a pointer to the document class.
  156.      CVarDoc* pDoc = GetDocument();
  157.  
  158.      // Change the value of m_MyVar to "Three".
  159.      pDoc->m_MyVar = "Three";
  160.  
  161.      // Tell the user that m_MyVar was changed to "Three".
  162.      MessageBox("m_MyVar is now: " + pDoc->m_MyVar);
  163.  
  164.      ////////////////////
  165.      // MY CODE ENDS HERE
  166.      ////////////////////
  167.  
  168.     
  169. }
  170.