AddUserDlg.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:4k
源码类别:

模拟服务器

开发平台:

C/C++

  1. // AddUserDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "S3DBClient.h"
  5. #include "AddUserDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CAddUserDlg dialog
  13. CAddUserDlg::CAddUserDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CAddUserDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CAddUserDlg)
  17. m_cstrName = _T("");
  18. m_cstrPassword = _T("");
  19. m_cstrPasswordCheck = _T("");
  20. m_cstrPriority = _T("");
  21. //}}AFX_DATA_INIT
  22. m_siPriority = 0;
  23. }
  24. void CAddUserDlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CAddUserDlg)
  28. DDX_Control(pDX, IDC_PRIORITY, m_priorityCtrl);
  29. DDX_Control(pDX, IDC_PASSWORDCHECK, m_passwordCheckCtrl);
  30. DDX_Control(pDX, IDC_PASSWORD, m_passwordCtrl);
  31. DDX_Control(pDX, IDC_NAME, m_nameCtrl);
  32. DDX_Text(pDX, IDC_NAME, m_cstrName);
  33. DDV_MaxChars(pDX, m_cstrName, 16);
  34. DDX_Text(pDX, IDC_PASSWORD, m_cstrPassword);
  35. DDV_MaxChars(pDX, m_cstrPassword, 16);
  36. DDX_Text(pDX, IDC_PASSWORDCHECK, m_cstrPasswordCheck);
  37. DDV_MaxChars(pDX, m_cstrPasswordCheck, 16);
  38. DDX_CBString(pDX, IDC_PRIORITY, m_cstrPriority);
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(CAddUserDlg, CDialog)
  42. //{{AFX_MSG_MAP(CAddUserDlg)
  43. ON_EN_CHANGE(IDC_NAME, OnChangeName)
  44. ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
  45. ON_EN_CHANGE(IDC_PASSWORDCHECK, OnChangePasswordcheck)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CAddUserDlg message handlers
  50. void CAddUserDlg::OnOK() 
  51. {
  52. // TODO: Add extra validation here
  53. if ( def_DBUSERNAME_MIN_LEN > m_cstrName.GetLength() )
  54. {
  55. MessageBox( "The length of name must be shorter than 16 and longer than 6" );
  56. m_nameCtrl.SetFocus();
  57. m_nameCtrl.SetSel( 0, -1 );
  58. return;
  59. }
  60. if ( def_DBPASSWORD_MIN_LEN > m_cstrPassword.GetLength() )
  61. {
  62. MessageBox( "The length of password must be shorter than 16 and longer than 6" );
  63. m_passwordCtrl.SetFocus();
  64. m_passwordCtrl.SetSel( 0, -1 );
  65. return;
  66. }
  67. if ( m_cstrPassword != m_cstrPasswordCheck )
  68. {
  69. MessageBox( "Checking password error." );
  70. m_passwordCheckCtrl.SetFocus();
  71. m_passwordCheckCtrl.SetSel( 0, -1 );
  72. return;
  73. }
  74. m_siPriority = m_priorityCtrl.GetCurSel();
  75. if ( ( m_siPriority < 0 )
  76. || ( m_siPriority > 3 ) )
  77. {
  78. m_siPriority = 0;
  79. m_priorityCtrl.SetFocus();
  80. m_priorityCtrl.SetCurSel( m_siPriority );
  81. return;
  82. }
  83. CDialog::OnOK();
  84. }
  85. void CAddUserDlg::OnCancel() 
  86. {
  87. // TODO: Add extra cleanup here
  88. CDialog::OnCancel();
  89. }
  90. void CAddUserDlg::OnChangeName() 
  91. {
  92. // TODO: If this is a RICHEDIT control, the control will not
  93. // send this notification unless you override the CDialog::OnInitDialog()
  94. // function and call CRichEditCtrl().SetEventMask()
  95. // with the ENM_CHANGE flag ORed into the mask.
  96. // TODO: Add your control notification handler code here
  97. UpdateData( TRUE );
  98. }
  99. void CAddUserDlg::OnChangePassword() 
  100. {
  101. // TODO: If this is a RICHEDIT control, the control will not
  102. // send this notification unless you override the CDialog::OnInitDialog()
  103. // function and call CRichEditCtrl().SetEventMask()
  104. // with the ENM_CHANGE flag ORed into the mask.
  105. // TODO: Add your control notification handler code here
  106. UpdateData( TRUE );
  107. }
  108. void CAddUserDlg::OnChangePasswordcheck() 
  109. {
  110. // TODO: If this is a RICHEDIT control, the control will not
  111. // send this notification unless you override the CDialog::OnInitDialog()
  112. // function and call CRichEditCtrl().SetEventMask()
  113. // with the ENM_CHANGE flag ORed into the mask.
  114. // TODO: Add your control notification handler code here
  115. UpdateData( TRUE );
  116. }
  117. BOOL CAddUserDlg::OnInitDialog() 
  118. {
  119. CDialog::OnInitDialog();
  120. // TODO: Add extra initialization here
  121. m_priorityCtrl.SetCurSel( m_siPriority );
  122. return TRUE;  // return TRUE unless you set the focus to a control
  123.               // EXCEPTION: OCX Property Pages should return FALSE
  124. }