home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch19 / pad / padview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-25  |  3.7 KB  |  173 lines

  1. // padview.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "pad.h"
  6.  
  7. //////////////////////
  8. // MY CODE STARTS HERE
  9. //////////////////////
  10.  
  11. #include "paddoc.h"
  12.  
  13. ////////////////////
  14. // MY CODE ENDS HERE
  15. ////////////////////
  16.  
  17. #include "padview.h"
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char BASED_CODE THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CPadView
  26.  
  27. IMPLEMENT_DYNCREATE(CPadView, CFormView)
  28.  
  29. CPadView::CPadView()
  30.     : CFormView(CPadView::IDD)
  31. {
  32.     //{{AFX_DATA_INIT(CPadView)
  33.     m_Subject = "";
  34.     m_Notes = "";
  35.     //}}AFX_DATA_INIT
  36. }
  37.  
  38. CPadView::~CPadView()
  39. {
  40. }
  41.  
  42. void CPadView::DoDataExchange(CDataExchange* pDX)
  43. {
  44.     CFormView::DoDataExchange(pDX);
  45.     //{{AFX_DATA_MAP(CPadView)
  46.     DDX_Text(pDX, IDC_SUBJECT, m_Subject);
  47.     DDX_Text(pDX, IDC_NOTES, m_Notes);
  48.     //}}AFX_DATA_MAP
  49. }
  50.  
  51.  
  52. BEGIN_MESSAGE_MAP(CPadView, CFormView)
  53.     //{{AFX_MSG_MAP(CPadView)
  54.     ON_EN_CHANGE(IDC_SUBJECT, OnChangeSubject)
  55.     ON_EN_CHANGE(IDC_NOTES, OnChangeNotes)
  56.     //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58.  
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CPadView message handlers
  62.  
  63. //////////////////////
  64. // MY CODE STARTS HERE
  65. //////////////////////
  66.  
  67. void CPadView::OnInitialUpdate()
  68. {
  69.  
  70.    // Get a pointer to the document.
  71.    CPadDoc* pDoc = (CPadDoc*) GetDocument();
  72.  
  73.    // Update the data members of the view class with the
  74.    // current values of the document class data members.
  75.    m_Subject = pDoc->m_Subject;
  76.    m_Notes   = pDoc->m_Notes;
  77.  
  78.    // Update the screen with the new values.
  79.    UpdateData(FALSE);
  80.  
  81. }
  82.  
  83. ////////////////////
  84. // MY CODE ENDS HERE
  85. ////////////////////
  86.  
  87. void CPadView::OnChangeSubject()
  88. {
  89.     // TODO: Add your control notification handler code here
  90.  
  91.     //////////////////////
  92.     // MY CODE STARTS HERE
  93.     //////////////////////
  94.  
  95.     // Update the variables of the controls with the
  96.     // current values inside the controls.
  97.     UpdateData(TRUE);
  98.  
  99.     // Get a pointer to the document.
  100.     CPadDoc* pDoc = (CPadDoc*) GetDocument();
  101.  
  102.     // Update the m_Subject data member of the document class.
  103.     pDoc->m_Subject = m_Subject;
  104.  
  105.     // Set the Modified flag of the document class to TRUE.
  106.     pDoc->SetModifiedFlag();
  107.  
  108.     // Update all the other views of the same document.
  109.     pDoc->UpdateAllViews(this);
  110.  
  111.     ////////////////////
  112.     // MY CODE ENDS HERE
  113.     ////////////////////
  114.     
  115. }
  116.  
  117. void CPadView::OnChangeNotes()
  118. {
  119.     // TODO: Add your control notification handler code here
  120.  
  121.     //////////////////////
  122.     // MY CODE STARTS HERE
  123.     //////////////////////
  124.  
  125.     // Update the variables of the controls with the
  126.     // current values inside the controls.
  127.     UpdateData(TRUE);
  128.  
  129.     // Get a pointer to the document.
  130.     CPadDoc* pDoc = (CPadDoc*) GetDocument();
  131.  
  132.     // Update the m_Notes data member of the document class.
  133.     pDoc->m_Notes = m_Notes;
  134.  
  135.     // Set the Modified flag of the document class to TRUE.
  136.     pDoc->SetModifiedFlag();
  137.  
  138.     // Update all the other views of the same document.
  139.     pDoc->UpdateAllViews(this);
  140.  
  141.     ////////////////////
  142.     // MY CODE ENDS HERE
  143.     ////////////////////
  144.     
  145. }
  146.  
  147.  
  148. //////////////////////
  149. // MY CODE STARTS HERE
  150. //////////////////////
  151.  
  152. void CPadView::OnUpdate(CView* pSender,
  153.                         LPARAM lHint,
  154.                         CObject* pHint)
  155. {
  156.  
  157.     // Get a pointer to the document.
  158.     CPadDoc* pDoc = (CPadDoc*) GetDocument();
  159.  
  160.     // Update the view with the current document values.
  161.     m_Subject = pDoc->m_Subject;
  162.     m_Notes   = pDoc->m_Notes;
  163.  
  164.     // Update the screen with the new variables values.
  165.     UpdateData(FALSE);
  166.  
  167. }
  168.  
  169. ////////////////////
  170. // MY CODE ENDS HERE
  171. ////////////////////
  172.  
  173.