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.

236 lines
6.5 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // GenSvc.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CGenericSvcParamsPage class.
  10. //
  11. // Author:
  12. // David Potter (davidp) June 28, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "CluAdmX.h"
  21. #include "ExtObj.h"
  22. #include "GenSvc.h"
  23. #include "DDxDDv.h"
  24. #include "HelpData.h"
  25. #include "ExcOper.h"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CGenericSvcParamsPage property page
  33. /////////////////////////////////////////////////////////////////////////////
  34. IMPLEMENT_DYNCREATE(CGenericSvcParamsPage, CBasePropertyPage)
  35. /////////////////////////////////////////////////////////////////////////////
  36. // Message Maps
  37. BEGIN_MESSAGE_MAP(CGenericSvcParamsPage, CBasePropertyPage)
  38. //{{AFX_MSG_MAP(CGenericSvcParamsPage)
  39. ON_EN_CHANGE(IDC_PP_GENSVC_PARAMS_SERVICE_NAME, OnChangeServiceName)
  40. //}}AFX_MSG_MAP
  41. ON_EN_CHANGE(IDC_PP_GENSVC_PARAMS_COMMAND_LINE, CBasePropertyPage::OnChangeCtrl)
  42. ON_BN_CLICKED(IDC_PP_GENSVC_PARAMS_USE_NETWORK_NAME, CBasePropertyPage::OnChangeCtrl)
  43. END_MESSAGE_MAP()
  44. /////////////////////////////////////////////////////////////////////////////
  45. //++
  46. //
  47. // CGenericSvcParamsPage::CGenericSvcParamsPage
  48. //
  49. // Routine Description:
  50. // Default constructor.
  51. //
  52. // Arguments:
  53. // None.
  54. //
  55. // Return Value:
  56. // None.
  57. //
  58. //--
  59. /////////////////////////////////////////////////////////////////////////////
  60. CGenericSvcParamsPage::CGenericSvcParamsPage(void)
  61. : CBasePropertyPage(g_aHelpIDs_IDD_PP_GENSVC_PARAMETERS, g_aHelpIDs_IDD_WIZ_GENSVC_PARAMETERS)
  62. {
  63. // TODO: Modify the following lines to represent the data displayed on this page.
  64. //{{AFX_DATA_INIT(CGenericSvcParamsPage)
  65. m_strServiceName = _T("");
  66. m_strCommandLine = _T("");
  67. m_bUseNetworkName = FALSE;
  68. //}}AFX_DATA_INIT
  69. m_bPrevUseNetworkName = FALSE;
  70. // Setup the property array.
  71. {
  72. m_rgProps[epropServiceName].Set(REGPARAM_GENSVC_SERVICE_NAME, m_strServiceName, m_strPrevServiceName);
  73. m_rgProps[epropCommandLine].Set(REGPARAM_GENSVC_COMMAND_LINE, m_strCommandLine, m_strPrevCommandLine);
  74. m_rgProps[epropUseNetworkName].Set(REGPARAM_GENSVC_USE_NETWORK_NAME, m_bUseNetworkName, m_bPrevUseNetworkName);
  75. } // Setup the property array
  76. m_iddPropertyPage = IDD_PP_GENSVC_PARAMETERS;
  77. m_iddWizardPage = IDD_WIZ_GENSVC_PARAMETERS;
  78. } //*** CGenericSvcParamsPage::CGenericSvcParamsPage()
  79. /////////////////////////////////////////////////////////////////////////////
  80. //++
  81. //
  82. // CGenericSvcParamsPage::DoDataExchange
  83. //
  84. // Routine Description:
  85. // Do data exchange between the dialog and the class.
  86. //
  87. // Arguments:
  88. // pDX [IN OUT] Data exchange object
  89. //
  90. // Return Value:
  91. // None.
  92. //
  93. //--
  94. /////////////////////////////////////////////////////////////////////////////
  95. void CGenericSvcParamsPage::DoDataExchange(CDataExchange * pDX)
  96. {
  97. if (!pDX->m_bSaveAndValidate || !BSaved())
  98. {
  99. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  100. // TODO: Modify the following lines to represent the data displayed on this page.
  101. //{{AFX_DATA_MAP(CGenericSvcParamsPage)
  102. DDX_Control(pDX, IDC_PP_GENSVC_PARAMS_USE_NETWORK_NAME, m_ckbUseNetworkName);
  103. DDX_Control(pDX, IDC_PP_GENSVC_PARAMS_SERVICE_NAME, m_editServiceName);
  104. DDX_Text(pDX, IDC_PP_GENSVC_PARAMS_SERVICE_NAME, m_strServiceName);
  105. DDX_Text(pDX, IDC_PP_GENSVC_PARAMS_COMMAND_LINE, m_strCommandLine);
  106. DDX_Check(pDX, IDC_PP_GENSVC_PARAMS_USE_NETWORK_NAME, m_bUseNetworkName);
  107. //}}AFX_DATA_MAP
  108. if (!BBackPressed())
  109. DDV_RequiredText(pDX, IDC_PP_GENSVC_PARAMS_SERVICE_NAME, IDC_PP_GENSVC_PARAMS_SERVICE_NAME_LABEL, m_strServiceName);
  110. } // if: not saving or haven't saved yet
  111. CBasePropertyPage::DoDataExchange(pDX);
  112. } //*** CGenericSvcParamsPage::DoDataExchange()
  113. /////////////////////////////////////////////////////////////////////////////
  114. //++
  115. //
  116. // CGenericSvcParamsPage::OnSetActive
  117. //
  118. // Routine Description:
  119. // Handler for the PSN_SETACTIVE message.
  120. //
  121. // Arguments:
  122. // None.
  123. //
  124. // Return Value:
  125. // TRUE Page successfully initialized.
  126. // FALSE Page not initialized.
  127. //
  128. //--
  129. /////////////////////////////////////////////////////////////////////////////
  130. BOOL CGenericSvcParamsPage::OnSetActive(void)
  131. {
  132. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  133. // If there is no network name, hide the UseNetworkName control.
  134. {
  135. WCHAR wszNetName[MAX_COMPUTERNAME_LENGTH + 1];
  136. DWORD nSize = sizeof(wszNetName) / sizeof(WCHAR);
  137. BOOL bNetNameExists;
  138. bNetNameExists = Peo()->BGetResourceNetworkName(
  139. wszNetName,
  140. &nSize
  141. );
  142. m_ckbUseNetworkName.EnableWindow(bNetNameExists);
  143. } // If there is no network name, hide the UseNetworkName control
  144. // Enable/disable the Next/Finish button.
  145. if (BWizard())
  146. {
  147. if (m_strServiceName.GetLength() == 0)
  148. EnableNext(FALSE);
  149. else
  150. EnableNext(TRUE);
  151. } // if: enable/disable the Next button
  152. return CBasePropertyPage::OnSetActive();
  153. } //*** CGenericSvcParamsPage::OnSetActive()
  154. /////////////////////////////////////////////////////////////////////////////
  155. //++
  156. //
  157. // CGenericSvcParamsPage::OnChangeSignature
  158. //
  159. // Routine Description:
  160. // Handler for the EN_CHANGE message on the Service Name edit control.
  161. //
  162. // Arguments:
  163. // None.
  164. //
  165. // Return Value:
  166. // None.
  167. //
  168. //--
  169. /////////////////////////////////////////////////////////////////////////////
  170. void CGenericSvcParamsPage::OnChangeServiceName(void)
  171. {
  172. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  173. OnChangeCtrl();
  174. if (BWizard())
  175. {
  176. if (m_editServiceName.GetWindowTextLength() == 0)
  177. EnableNext(FALSE);
  178. else
  179. EnableNext(TRUE);
  180. } // if: in a wizard
  181. } //*** CGenericSvcParamsPage::OnChangeServiceName()
  182. /////////////////////////////////////////////////////////////////////////////
  183. //++
  184. //
  185. // CGenericSvcParamsPage::DisplaySetPropsError
  186. //
  187. // Routine Description:
  188. // Display an error caused by setting or validating properties.
  189. //
  190. // Arguments:
  191. // dwStatus [IN] Status to display error on.
  192. //
  193. // Return Value:
  194. // dwStatus ERROR_SUCCESS = success, !0 = failure
  195. //
  196. //--
  197. /////////////////////////////////////////////////////////////////////////////
  198. void CGenericSvcParamsPage::DisplaySetPropsError(IN DWORD dwStatus) const
  199. {
  200. CString strMsg;
  201. if (dwStatus == ERROR_NOT_SUPPORTED)
  202. strMsg.FormatMessage(IDS_INVALID_GENERIC_SERVICE, m_strServiceName);
  203. else
  204. FormatError(strMsg, dwStatus);
  205. AfxMessageBox(strMsg, MB_OK | MB_ICONSTOP);
  206. } //*** CGenericSvcParamsPage::DisplaySetPropsError()