Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. edituser.h
  7. Edit user dialog implementation file
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "AddServ.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CAddServ dialog
  19. CAddServ::CAddServ(CWnd* pParent /*=NULL*/)
  20. : CBaseDialog(CAddServ::IDD, pParent)
  21. {
  22. //{{AFX_DATA_INIT(CAddServ)
  23. // NOTE: the ClassWizard will add member initialization here
  24. //}}AFX_DATA_INIT
  25. }
  26. void CAddServ::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CBaseDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CAddServ)
  30. DDX_Control(pDX, IDC_ADD_EDIT_NAME, m_editComputerName);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CAddServ, CBaseDialog)
  34. //{{AFX_MSG_MAP(CAddServ)
  35. ON_BN_CLICKED(IDC_BTN_BROWSE, OnButtonBrowse)
  36. ON_BN_CLICKED(IDC_ADD_LOCAL, OnRadioBtnClicked)
  37. ON_BN_CLICKED(IDC_ADD_OTHER, OnRadioBtnClicked)
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CAddServ message handlers
  42. BOOL CAddServ::OnInitDialog()
  43. {
  44. CBaseDialog::OnInitDialog();
  45. CheckDlgButton(IDC_ADD_OTHER, BST_CHECKED);
  46. m_editComputerName.SetFocus();
  47. OnRadioBtnClicked();
  48. return FALSE; // return TRUE unless you set the focus to a control
  49. // EXCEPTION: OCX Property Pages should return FALSE
  50. }
  51. void CAddServ::OnButtonBrowse()
  52. {
  53. CGetComputer getComputer;
  54. if (!getComputer.GetComputer(GetSafeHwnd()))
  55. return;
  56. CString strTemp = getComputer.m_strComputerName;
  57. m_editComputerName.SetWindowText(strTemp);
  58. }
  59. void CAddServ::OnRadioBtnClicked()
  60. {
  61. BOOL fEnable = IsDlgButtonChecked(IDC_ADD_OTHER);
  62. m_editComputerName.EnableWindow(fEnable);
  63. GetDlgItem(IDC_BTN_BROWSE)->EnableWindow(fEnable);
  64. }
  65. void CAddServ::OnOK()
  66. {
  67. DWORD dwLength;
  68. if (IsDlgButtonChecked(IDC_ADD_OTHER))
  69. {
  70. dwLength = m_editComputerName.GetWindowTextLength() + 1;
  71. if (dwLength <= 1)
  72. {
  73. AfxMessageBox(IDS_ERR_EMPTY_NAME);
  74. return;
  75. }
  76. m_editComputerName.GetWindowText(m_stComputerName.GetBuffer(dwLength), dwLength);
  77. }
  78. else
  79. {
  80. dwLength = MAX_COMPUTERNAME_LENGTH + 1;
  81. GetComputerName(m_stComputerName.GetBuffer(dwLength), &dwLength);
  82. }
  83. m_stComputerName.ReleaseBuffer();
  84. CBaseDialog::OnOK();
  85. }