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.

238 lines
7.0 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusName.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CChangeClusterNameDlg class.
  10. //
  11. // Author:
  12. // David Potter (davidp) April 28, 1997
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "CluAdmX.h"
  21. #include "ClusName.h"
  22. #include "DDxDDv.h"
  23. #include "HelpData.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CChangeClusterNameDlg dialog
  31. /////////////////////////////////////////////////////////////////////////////
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Message Maps
  34. BEGIN_MESSAGE_MAP(CChangeClusterNameDlg, CBaseDialog)
  35. //{{AFX_MSG_MAP(CChangeClusterNameDlg)
  36. ON_EN_CHANGE(IDC_CLUSNAME, OnChangeClusName)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. //++
  41. //
  42. // CChangeClusterNameDlg::CChangeClusterNameDlg
  43. //
  44. // Routine Description:
  45. // Constructor.
  46. //
  47. // Arguments:
  48. // pParent [IN] Parent window for the dialog.
  49. //
  50. // Return Value:
  51. // None.
  52. //
  53. //--
  54. /////////////////////////////////////////////////////////////////////////////
  55. CChangeClusterNameDlg::CChangeClusterNameDlg(CWnd * pParent /*=NULL*/)
  56. : CBaseDialog(IDD, g_aHelpIDs_IDD_EDIT_CLUSTER_NAME, pParent)
  57. {
  58. //{{AFX_DATA_INIT(CChangeClusterNameDlg)
  59. m_strClusName = _T("");
  60. //}}AFX_DATA_INIT
  61. } //*** CChangeClusterNameDlg::CChangeClusterNameDlg()
  62. /////////////////////////////////////////////////////////////////////////////
  63. //++
  64. //
  65. // CChangeClusterNameDlg::DoDataExchange
  66. //
  67. // Routine Description:
  68. // Do data exchange between the dialog and the class.
  69. //
  70. // Arguments:
  71. // pDX [IN OUT] Data exchange object
  72. //
  73. // Return Value:
  74. // None.
  75. //
  76. //--
  77. /////////////////////////////////////////////////////////////////////////////
  78. void CChangeClusterNameDlg::DoDataExchange(CDataExchange * pDX)
  79. {
  80. CWaitCursor wc;
  81. CString strClusName;
  82. CBaseDialog::DoDataExchange(pDX);
  83. //{{AFX_DATA_MAP(CChangeClusterNameDlg)
  84. DDX_Control(pDX, IDOK, m_pbOK);
  85. DDX_Control(pDX, IDC_CLUSNAME, m_editClusName);
  86. //}}AFX_DATA_MAP
  87. if (pDX->m_bSaveAndValidate)
  88. {
  89. CLRTL_NAME_STATUS cnStatus;
  90. //
  91. // get the name from the control into a temp variable
  92. //
  93. DDX_Text(pDX, IDC_CLUSNAME, strClusName);
  94. DDV_RequiredText(pDX, IDC_CLUSNAME, IDC_CLUSNAME_LABEL, m_strClusName);
  95. DDV_MaxChars(pDX, m_strClusName, MAX_CLUSTERNAME_LENGTH);
  96. //
  97. // Only do work if the names are different.
  98. //
  99. if ( m_strClusName != strClusName )
  100. {
  101. //
  102. // Check to see if the new name is valid
  103. //
  104. if( !ClRtlIsNetNameValid(strClusName, &cnStatus, FALSE /*CheckIfExists*/) )
  105. {
  106. //
  107. // The net name is not valid. Display a message box with the error.
  108. //
  109. CString strMsg;
  110. UINT idsError;
  111. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  112. switch (cnStatus)
  113. {
  114. case NetNameTooLong:
  115. idsError = IDS_INVALID_NETWORK_NAME_TOO_LONG;
  116. break;
  117. case NetNameInvalidChars:
  118. idsError = IDS_INVALID_NETWORK_NAME_INVALID_CHARS;
  119. break;
  120. case NetNameInUse:
  121. idsError = IDS_INVALID_NETWORK_NAME_IN_USE;
  122. break;
  123. case NetNameDNSNonRFCChars:
  124. idsError = IDS_INVALID_NETWORK_NAME_INVALID_DNS_CHARS;
  125. break;
  126. default:
  127. idsError = IDS_INVALID_NETWORK_NAME;
  128. break;
  129. } // switch: cnStatus
  130. strMsg.LoadString(idsError);
  131. if ( idsError == IDS_INVALID_NETWORK_NAME_INVALID_DNS_CHARS )
  132. {
  133. int id = AfxMessageBox(strMsg, MB_YESNO | MB_DEFBUTTON2 | MB_ICONEXCLAMATION );
  134. if ( id == IDNO )
  135. {
  136. strMsg.Empty();
  137. pDX->Fail();
  138. }
  139. }
  140. else
  141. {
  142. AfxMessageBox(strMsg, MB_ICONEXCLAMATION);
  143. strMsg.Empty(); // exception prep
  144. pDX->Fail();
  145. }
  146. } // if: netname has changed and an invalid network name was specified
  147. //
  148. // A valid netname was entered or a non-standard netname was confirmed.
  149. // Save it.
  150. //
  151. m_strClusName = strClusName;
  152. } // if: names are different
  153. } // if: saving data from dialog
  154. else
  155. {
  156. //
  157. // populate the control with data from the member variable
  158. //
  159. DDX_Text(pDX, IDC_CLUSNAME, m_strClusName);
  160. }
  161. } //*** CChangeClusterNameDlg::DoDataExchange()
  162. /////////////////////////////////////////////////////////////////////////////
  163. //++
  164. //
  165. // CChangeClusterNameDlg::OnInitDialog
  166. //
  167. // Routine Description:
  168. // Handler for the WM_INITDIALOG message.
  169. //
  170. // Arguments:
  171. // None.
  172. //
  173. // Return Value:
  174. // TRUE We need the focus to be set for us.
  175. // FALSE We already set the focus to the proper control.
  176. //
  177. //--
  178. /////////////////////////////////////////////////////////////////////////////
  179. BOOL CChangeClusterNameDlg::OnInitDialog(void)
  180. {
  181. CBaseDialog::OnInitDialog();
  182. if (m_strClusName.GetLength() == 0)
  183. m_pbOK.EnableWindow(FALSE);
  184. m_editClusName.SetLimitText(MAX_CLUSTERNAME_LENGTH);
  185. return TRUE; // return TRUE unless you set the focus to a control
  186. // EXCEPTION: OCX Property Pages should return FALSE
  187. } //*** CChangeClusterNameDlg::OnInitDialog()
  188. /////////////////////////////////////////////////////////////////////////////
  189. //++
  190. //
  191. // CChangeClusterNameDlg::OnChangeClusName
  192. //
  193. // Routine Description:
  194. // Handler for the EN_CHANGE message on the Name edit control.
  195. //
  196. // Arguments:
  197. // None.
  198. //
  199. // Return Value:
  200. // TRUE Page successfully applied.
  201. // FALSE Error applying page.
  202. //
  203. //--
  204. /////////////////////////////////////////////////////////////////////////////
  205. void CChangeClusterNameDlg::OnChangeClusName(void)
  206. {
  207. BOOL bEnable;
  208. bEnable = (m_editClusName.GetWindowTextLength() > 0);
  209. m_pbOK.EnableWindow(bEnable);
  210. } //*** CChangeClusterNameDlg::OnChangeClusName()