home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c07 / treelist / dialogs.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.7 KB  |  152 lines

  1. // Dialogs.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tree.h"
  6.  
  7. #include "dialogs.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CAnimalDlg dialog
  17. CAnimalDlg::CAnimalDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CAnimalDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CAnimalDlg)
  21.     m_animal = _T("");
  22.     m_type = _T("");
  23.     m_weight = 0;
  24.     m_class = _T("");
  25.     //}}AFX_DATA_INIT
  26. }
  27.  
  28. void CAnimalDlg::DoDataExchange(CDataExchange* pDX)
  29. {
  30.     CDialog::DoDataExchange(pDX);
  31.     //{{AFX_DATA_MAP(CAnimalDlg)
  32.     DDX_Control(pDX, IDC_CLASS_LIST, m_classNames);
  33.     DDX_Text(pDX, IDC_ANIMAL, m_animal);
  34.     DDX_Text(pDX, IDC_TYPE, m_type);
  35.     DDX_Text(pDX, IDC_WEIGHT, m_weight);
  36.     DDX_LBString(pDX, IDC_CLASS_LIST, m_class);
  37.     //}}AFX_DATA_MAP
  38. }
  39.  
  40. BEGIN_MESSAGE_MAP(CAnimalDlg, CDialog)
  41.     //{{AFX_MSG_MAP(CAnimalDlg)
  42.     //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CAnimalDlg message handlers
  47.  
  48. BOOL CAnimalDlg::OnInitDialog() 
  49. {
  50.     CDialog::OnInitDialog();
  51.     
  52.     CString s;
  53.     
  54.     // Insert the class names into the list box and 
  55.     // set the default selection to 0 ...
  56.     for (int i = IDS_AMPHIBIANS; i <= IDS_REPTILES; i++)
  57.     {
  58.         s.LoadString(i);
  59.         m_classNames.AddString(s);
  60.     }
  61.     m_classNames.SetCurSel(0);
  62.  
  63.     // and then size the list box.
  64.     CRect rect;
  65.     int itemHeight;
  66.     m_classNames.GetClientRect(&rect);
  67.     m_classNames.MapWindowPoints(this, &rect);
  68.     // Increase each item's height by 1.
  69.     itemHeight = m_classNames.GetItemHeight(0) + 1;
  70.     rect.bottom = rect.top + ((IDS_REPTILES - IDS_AMPHIBIANS) + 1) * itemHeight;
  71.     m_classNames.MoveWindow(&rect);
  72.     
  73.     return TRUE;
  74. }
  75.  
  76. // ModifyDlg.cpp : implementation
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CModifyDlg dialog
  79. CModifyDlg::CModifyDlg(CWnd* pParent /*=NULL*/)
  80.     : CDialog(CModifyDlg::IDD, pParent)
  81. {
  82.     //{{AFX_DATA_INIT(CModifyDlg)
  83.     m_animal = _T("");
  84.     m_weight = 0;
  85.     //}}AFX_DATA_INIT
  86. }
  87.  
  88. void CModifyDlg::DoDataExchange(CDataExchange* pDX)
  89. {
  90.     CDialog::DoDataExchange(pDX);
  91.     //{{AFX_DATA_MAP(CModifyDlg)
  92.     DDX_Text(pDX, IDC_ANIMAL, m_animal);
  93.     DDX_Text(pDX, IDC_WEIGHT, m_weight);
  94.     //}}AFX_DATA_MAP
  95. }
  96.  
  97. BEGIN_MESSAGE_MAP(CModifyDlg, CDialog)
  98.     //{{AFX_MSG_MAP(CModifyDlg)
  99.         // NOTE: the ClassWizard will add message map macros here
  100.     //}}AFX_MSG_MAP
  101. END_MESSAGE_MAP()
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CModifyDlg message handlers
  105.  
  106.  
  107. // ModifyTypeDlg.cpp : implementation
  108. /////////////////////////////////////////////////////////////////////////////
  109. // CModifyTypeDlg dialog
  110. CModifyTypeDlg::CModifyTypeDlg(CWnd* pParent /*=NULL*/)
  111.     : CDialog(CModifyTypeDlg::IDD, pParent)
  112. {
  113.     //{{AFX_DATA_INIT(CModifyTypeDlg)
  114.     m_type = _T("");
  115.     //}}AFX_DATA_INIT
  116. }
  117.  
  118. void CModifyTypeDlg::DoDataExchange(CDataExchange* pDX)
  119. {
  120.     CDialog::DoDataExchange(pDX);
  121.     //{{AFX_DATA_MAP(CModifyTypeDlg)
  122.     DDX_Text(pDX, IDC_TYPE, m_type);
  123.     //}}AFX_DATA_MAP
  124. }
  125.  
  126. BEGIN_MESSAGE_MAP(CModifyTypeDlg, CDialog)
  127.     //{{AFX_MSG_MAP(CModifyTypeDlg)
  128.     ON_EN_CHANGE(IDC_TYPE, OnChangeType)
  129.     //}}AFX_MSG_MAP
  130. END_MESSAGE_MAP()
  131.  
  132. /////////////////////////////////////////////////////////////////////////////
  133. // CModifyTypeDlg message handlers
  134.  
  135. void CModifyTypeDlg::OnChangeType() 
  136. {
  137.     CButton * pButton = (CButton *) GetDlgItem(IDOK);
  138.     pButton->EnableWindow(TRUE);
  139. }
  140.  
  141. BOOL CModifyTypeDlg::OnInitDialog() 
  142. {
  143.     CDialog::OnInitDialog();
  144.  
  145.     // Initially, the OK button is disabled. When the user changes
  146.     // the edit control, it's enabled.
  147.     CButton * pButton = (CButton *) GetDlgItem(IDOK);
  148.     pButton->EnableWindow(FALSE);
  149.     
  150.     return TRUE;
  151. }
  152.