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.

391 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. defws.cpp
  5. Abstract:
  6. Default Web Site Dialog
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "fscfg.h"
  18. #include "defws.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. //
  25. // Master Property Page
  26. //
  27. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  28. IMPLEMENT_DYNCREATE(CDefWebSitePage, CInetPropertyPage)
  29. CDefWebSitePage::CDefWebSitePage(
  30. IN CInetPropertySheet * pSheet
  31. )
  32. /*++
  33. Routine Description:
  34. Constructor for WWW Default Web Site page
  35. Arguments:
  36. CInetPropertySheet * pSheet : Sheet object
  37. Return Value:
  38. N/A
  39. --*/
  40. : CInetPropertyPage(CDefWebSitePage::IDD, pSheet),
  41. m_rgdwInstances()
  42. {
  43. //{{AFX_DATA_INIT(CDefWebSitePage)
  44. //}}AFX_DATA_INIT
  45. }
  46. CDefWebSitePage::~CDefWebSitePage()
  47. /*++
  48. Routine Description:
  49. Destructor
  50. Arguments:
  51. N/A
  52. Return Value:
  53. N/A
  54. --*/
  55. {
  56. }
  57. void
  58. CDefWebSitePage::DoDataExchange(
  59. IN CDataExchange * pDX
  60. )
  61. /*++
  62. Routine Description:
  63. Initialise/Store control data
  64. Arguments:
  65. CDataExchange * pDX - DDX/DDV control structure
  66. Return Value:
  67. None
  68. --*/
  69. {
  70. CInetPropertyPage::DoDataExchange(pDX);
  71. //{{AFX_DATA_MAP(CDefWebSitePage)
  72. DDX_Control(pDX, IDC_COMBO_WEBSITES, m_combo_WebSites);
  73. //}}AFX_DATA_MAP
  74. }
  75. //
  76. // Message Map
  77. //
  78. BEGIN_MESSAGE_MAP(CDefWebSitePage, CInetPropertyPage)
  79. //{{AFX_MSG_MAP(CDefWebSitePage)
  80. ON_CBN_SELCHANGE(IDC_COMBO_WEBSITES, OnSelchangeComboWebsites)
  81. //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83. HRESULT
  84. CDefWebSitePage::BuildInstanceList()
  85. /*++
  86. Routine Description:
  87. Build the instance list of friendly instances
  88. Arguments:
  89. None
  90. Return Value:
  91. Error return code
  92. --*/
  93. {
  94. CWaitCursor wait;
  95. //
  96. // Create interface
  97. //
  98. CMetaKey mk(QueryServerName());
  99. CError err(mk.QueryResult());
  100. if (err.Failed())
  101. {
  102. return err;
  103. }
  104. //
  105. // Populate combo box with known web sites.
  106. //
  107. ISMINSTANCEINFO ii;
  108. ii.dwSize = sizeof(ISMINSTANCEINFO);
  109. HANDLE hEnum = NULL;
  110. int i = 0;
  111. int iSel = LB_ERR;
  112. FOREVER
  113. {
  114. err = COMDLL_ISMEnumerateInstances(&mk, &ii, &hEnum, g_cszSvc);
  115. if (err.Failed())
  116. {
  117. break;
  118. }
  119. CString strComment(ii.szComment);
  120. if (strComment.IsEmpty())
  121. {
  122. //
  123. // This should be rare -- an instance without a name
  124. // just use the number.
  125. //
  126. {
  127. CString str;
  128. VERIFY(str.LoadString(IDS_INSTANCE_DEF_FMT));
  129. strComment.Format(
  130. str,
  131. g_cszSvc,
  132. ii.dwID
  133. );
  134. }
  135. }
  136. m_combo_WebSites.AddString(strComment);
  137. m_rgdwInstances.Add(ii.dwID);
  138. if (m_dwDownlevelInstance == ii.dwID)
  139. {
  140. //
  141. // This is the current one, remember the selection
  142. //
  143. iSel = i;
  144. }
  145. ++i;
  146. }
  147. m_rgdwInstances.FreeExtra();
  148. m_combo_WebSites.SetCurSel(iSel);
  149. if (err.Win32Error() == ERROR_NO_MORE_ITEMS)
  150. {
  151. //
  152. // Normal way to end the loop
  153. //
  154. err.Reset();
  155. }
  156. return err;
  157. }
  158. DWORD
  159. CDefWebSitePage::FetchInstanceSelected()
  160. /*++
  161. Routine Description:
  162. Based on the selection in the combo box, fetch the instance number
  163. selected.
  164. Arguments:
  165. None
  166. Return Value:
  167. The instance number coresponding to the selected instance, or -1.
  168. --*/
  169. {
  170. DWORD dwInstance = -1;
  171. int iSel = m_combo_WebSites.GetCurSel();
  172. if (iSel >= 0)
  173. {
  174. dwInstance = m_rgdwInstances[iSel];
  175. }
  176. return dwInstance;
  177. }
  178. /* virtual */
  179. HRESULT
  180. CDefWebSitePage::FetchLoadedValues()
  181. /*++
  182. Routine Description:
  183. Move configuration data from sheet to dialog controls
  184. Arguments:
  185. None
  186. Return Value:
  187. HRESULT
  188. --*/
  189. {
  190. CError err;
  191. BEGIN_META_INST_READ(CFtpSheet)
  192. FETCH_INST_DATA_FROM_SHEET(m_dwDownlevelInstance);
  193. END_META_INST_READ(err)
  194. m_rgdwInstances.SetSize(0, 10);
  195. return err;
  196. }
  197. /* virtual */
  198. HRESULT
  199. CDefWebSitePage::SaveInfo()
  200. /*++
  201. Routine Description:
  202. Save the information on this property page
  203. Arguments:
  204. None
  205. Return Value:
  206. Error return code
  207. --*/
  208. {
  209. ASSERT(IsDirty());
  210. TRACEEOLID("Saving W3 default web site page now...");
  211. CError err;
  212. m_dwDownlevelInstance = FetchInstanceSelected();
  213. BeginWaitCursor();
  214. BEGIN_META_INST_WRITE(CFtpSheet)
  215. STORE_INST_DATA_ON_SHEET(m_dwDownlevelInstance);
  216. END_META_INST_WRITE(err)
  217. EndWaitCursor();
  218. return err;
  219. }
  220. //
  221. // Message Handlers
  222. //
  223. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  224. BOOL
  225. CDefWebSitePage::OnInitDialog()
  226. /*++
  227. Routine Description:
  228. WM_INITDIALOG handler. Initialize the dialog.
  229. Arguments:
  230. None.
  231. Return Value:
  232. TRUE if focus is to be set automatically, FALSE if the focus
  233. is already set.
  234. --*/
  235. {
  236. CInetPropertyPage::OnInitDialog();
  237. CError err(BuildInstanceList());
  238. err.MessageBoxOnFailure();
  239. return TRUE;
  240. }
  241. void
  242. CDefWebSitePage::OnSelchangeComboWebsites()
  243. /*++
  244. Routine Description:
  245. web site combo box 'selection change' handler
  246. Arguments:
  247. None
  248. Return Value:
  249. None
  250. --*/
  251. {
  252. SetModified(TRUE);
  253. }