Source code of Windows XP (NT5)
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
6.8 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 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. else
  148. {
  149. //
  150. // A valid netname was entered - save it
  151. //
  152. m_strClusName = strClusName;
  153. }
  154. } // if: names are different
  155. } // if: saving data from dialog
  156. else
  157. {
  158. //
  159. // populate the control with data from the member variable
  160. //
  161. DDX_Text(pDX, IDC_CLUSNAME, m_strClusName);
  162. }
  163. } //*** CChangeClusterNameDlg::DoDataExchange()
  164. /////////////////////////////////////////////////////////////////////////////
  165. //++
  166. //
  167. // CChangeClusterNameDlg::OnInitDialog
  168. //
  169. // Routine Description:
  170. // Handler for the WM_INITDIALOG message.
  171. //
  172. // Arguments:
  173. // None.
  174. //
  175. // Return Value:
  176. // TRUE We need the focus to be set for us.
  177. // FALSE We already set the focus to the proper control.
  178. //
  179. //--
  180. /////////////////////////////////////////////////////////////////////////////
  181. BOOL CChangeClusterNameDlg::OnInitDialog(void)
  182. {
  183. CBaseDialog::OnInitDialog();
  184. if (m_strClusName.GetLength() == 0)
  185. m_pbOK.EnableWindow(FALSE);
  186. m_editClusName.SetLimitText(MAX_CLUSTERNAME_LENGTH);
  187. return TRUE; // return TRUE unless you set the focus to a control
  188. // EXCEPTION: OCX Property Pages should return FALSE
  189. } //*** CChangeClusterNameDlg::OnInitDialog()
  190. /////////////////////////////////////////////////////////////////////////////
  191. //++
  192. //
  193. // CChangeClusterNameDlg::OnChangeClusName
  194. //
  195. // Routine Description:
  196. // Handler for the EN_CHANGE message on the Name edit control.
  197. //
  198. // Arguments:
  199. // None.
  200. //
  201. // Return Value:
  202. // TRUE Page successfully applied.
  203. // FALSE Error applying page.
  204. //
  205. //--
  206. /////////////////////////////////////////////////////////////////////////////
  207. void CChangeClusterNameDlg::OnChangeClusName(void)
  208. {
  209. BOOL bEnable;
  210. bEnable = (m_editClusName.GetWindowTextLength() > 0);
  211. m_pbOK.EnableWindow(bEnable);
  212. } //*** CChangeClusterNameDlg::OnChangeClusName()