home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch08 / chkbox / mydlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-17  |  3.1 KB  |  160 lines

  1. // mydlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "chkbox.h"
  6. #include "mydlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMyDlg dialog
  15.  
  16.  
  17. CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CMyDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CMyDlg)
  21.     
  22.     //////////////////////
  23.     // MY CODE STARTS HERE
  24.     //////////////////////
  25.  
  26.      m_CheckBoxStatus = 1;
  27.      m_EditBoxContents = "I was updated inside CMyDlg()";
  28.  
  29.  
  30.     ////////////////////
  31.     // MY CODE ENDS HERE
  32.     ////////////////////
  33.          
  34.     //}}AFX_DATA_INIT
  35. }
  36.  
  37. void CMyDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39.     CDialog::DoDataExchange(pDX);
  40.     //{{AFX_DATA_MAP(CMyDlg)
  41.     DDX_Check(pDX, IDC_MY_CHECK_BOX, m_CheckBoxStatus);
  42.     DDX_Text(pDX, IDC_MY_EDIT_BOX, m_EditBoxContents);
  43.     //}}AFX_DATA_MAP
  44. }
  45.  
  46. BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
  47.     //{{AFX_MSG_MAP(CMyDlg)
  48.     ON_BN_CLICKED(IDC_MY_CHECK_BOX, OnMyCheckBox)
  49.     ON_BN_CLICKED(IDC_DISABLE, OnDisable)
  50.     ON_BN_CLICKED(IDC_ENABLE, OnEnable)
  51.     ON_BN_CLICKED(IDC_HIDE, OnHide)
  52.     ON_BN_CLICKED(IDC_SHOW, OnShow)
  53.     //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55.  
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CMyDlg message handlers
  59.  
  60.  
  61. void CMyDlg::OnMyCheckBox()
  62. {
  63.     // TODO: Add your control notification handler code here
  64.     
  65. //////////////////////
  66. // MY CODE STARTS HERE
  67. //////////////////////
  68.  
  69. // Update the variables, based on the contents of the
  70. // controls.
  71. UpdateData ( TRUE );
  72.  
  73.  
  74. // Based on the value of the check box variable,
  75. // update the variable of the edit box.   
  76. if ( m_CheckBoxStatus == 1 )
  77.      m_EditBoxContents = "My Check Box is checked.";
  78.  
  79.  
  80. if ( m_CheckBoxStatus == 0 )
  81.      m_EditBoxContents = "My Check Box is not checked.";
  82.  
  83. // Update the contents of the controls based on the values
  84. // of the variables,
  85. UpdateData ( FALSE );
  86.  
  87. ////////////////////
  88. // MY CODE ENDS HERE
  89. ////////////////////
  90.  
  91.  
  92. }
  93.  
  94. void CMyDlg::OnDisable()
  95. {
  96.     // TODO: Add your control notification handler code here
  97.  
  98. //////////////////////
  99. // MY CODE STARTS HERE
  100. //////////////////////
  101.  
  102. GetDlgItem(IDC_MY_CHECK_BOX)->EnableWindow(FALSE);
  103.  
  104. ////////////////////
  105. // MY CODE ENDS HERE
  106. ////////////////////
  107.  
  108. }
  109.  
  110. void CMyDlg::OnEnable()
  111. {
  112.     // TODO: Add your control notification handler code here
  113.  
  114. //////////////////////
  115. // MY CODE STARTS HERE
  116. //////////////////////
  117.  
  118. GetDlgItem(IDC_MY_CHECK_BOX)->EnableWindow(TRUE);
  119.  
  120. ////////////////////
  121. // MY CODE ENDS HERE
  122. ////////////////////
  123.  
  124.     
  125. }
  126.  
  127. void CMyDlg::OnHide()
  128. {
  129.     // TODO: Add your control notification handler code here
  130.  
  131. //////////////////////
  132. // MY CODE STARTS HERE
  133. //////////////////////
  134.  
  135. GetDlgItem(IDC_MY_CHECK_BOX)->ShowWindow(SW_HIDE);
  136.  
  137. ////////////////////
  138. // MY CODE ENDS HERE
  139. ////////////////////
  140.     
  141. }
  142.  
  143. void CMyDlg::OnShow()
  144. {
  145.     // TODO: Add your control notification handler code here
  146.  
  147. //////////////////////
  148. // MY CODE STARTS HERE
  149. //////////////////////
  150.  
  151. GetDlgItem(IDC_MY_CHECK_BOX)->ShowWindow(SW_SHOW);
  152.  
  153. ////////////////////
  154. // MY CODE ENDS HERE
  155. ////////////////////
  156.  
  157.     
  158. }
  159.  
  160.