home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c10 / lab02 / baseline / dlgfield.cpp next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.2 KB  |  89 lines

  1. // DlgField.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "MDB.h"
  6. #include "DlgField.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CDlgField dialog
  16.  
  17.  
  18. CDlgField::CDlgField(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CDlgField::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CDlgField)
  22.     m_strFieldName = _T("");
  23.     m_nTextLength = 1;
  24.     m_nFieldType = 0;
  25.     //}}AFX_DATA_INIT
  26. }
  27.  
  28.  
  29. void CDlgField::DoDataExchange(CDataExchange* pDX)
  30. {
  31.     CDialog::DoDataExchange(pDX);
  32.     //{{AFX_DATA_MAP(CDlgField)
  33.     DDX_Text(pDX, IDC_FIELD_NAME, m_strFieldName);
  34.     DDX_Text(pDX, IDC_FIELD_TEXT_LEN, m_nTextLength);
  35.     DDV_MinMaxInt(pDX, m_nTextLength, 1, 255);
  36.     DDX_Radio(pDX, IDC_FIELD_TYPE, m_nFieldType);
  37.     //}}AFX_DATA_MAP
  38.  
  39.     if ( ! pDX->m_bSaveAndValidate )
  40.     {
  41.         SetWindowText( m_strCaption );
  42.         if ( m_nFieldType )  //Non-text field
  43.             OnFieldTypeNumeric( );
  44.         else
  45.             OnFieldTypeText( );
  46.         OnChangeFieldName( );
  47.     }
  48. }
  49.  
  50.  
  51. BEGIN_MESSAGE_MAP(CDlgField, CDialog)
  52.     //{{AFX_MSG_MAP(CDlgField)
  53.     ON_BN_CLICKED(IDC_FIELD_TYPE, OnFieldTypeText)
  54.     ON_BN_CLICKED(IDC_FIELD_TYPE2, OnFieldTypeNumeric)
  55.     ON_BN_CLICKED(IDC_FIELD_TYPE3, OnFieldTypeNumeric)
  56.     ON_EN_CHANGE(IDC_FIELD_NAME, OnChangeFieldName)
  57.     //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CDlgField message handlers
  62.  
  63.  
  64. void CDlgField::OnFieldTypeText() 
  65. {
  66.     // TODO: Add your control notification handler code here
  67.     
  68.     CEdit * pEdit = ( CEdit * ) GetDlgItem( IDC_FIELD_TEXT_LEN );
  69.     pEdit->SetReadOnly( FALSE );
  70.     GetDlgItem( IDC_FIELD_TEXT_LEN )->SetFocus( );
  71. }
  72.  
  73. void CDlgField::OnFieldTypeNumeric() 
  74. {
  75.     // TODO: Add your control notification handler code here
  76.     
  77.     CEdit * pEdit = ( CEdit * ) GetDlgItem( IDC_FIELD_TEXT_LEN );
  78.     pEdit->SetReadOnly( TRUE );
  79. }
  80.  
  81. void CDlgField::OnChangeFieldName() 
  82. {
  83.     // TODO: Add your control notification handler code here
  84.  
  85.     CEdit * pEdit = ( CEdit * ) GetDlgItem( IDC_FIELD_NAME );
  86.     CButton * pBtn = ( CButton * ) GetDlgItem( IDOK );
  87.     pBtn->EnableWindow( pEdit->LineLength( ) );
  88. }
  89.