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.

356 lines
11 KiB

  1. // ***************************************************************************
  2. #include "pch.h"
  3. #pragma hdrstop
  4. #include "resource.h"
  5. #include "wizard.h"
  6. #include "ncreg.h"
  7. #include "ncui.h"
  8. extern const WCHAR c_szEmpty[];
  9. // ***************************************************************************
  10. // Function: OnISPPageActivate
  11. //
  12. // Purpose: Handle the PSN_SETACTIVE notification
  13. //
  14. // Parameters: hwndDlg [IN] - Handle to the ISP dialog
  15. //
  16. // Returns: BOOL
  17. // ***************************************************************************
  18. BOOL OnISPPageActivate(HWND hwndDlg)
  19. {
  20. TraceFileFunc(ttidGuiModeSetup);
  21. TraceTag(ttidWizard, "Entering ISP Menu page...");
  22. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 0L);
  23. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT | PSWIZB_BACK);
  24. CWizard * pWizard =
  25. reinterpret_cast<CWizard *>(::GetWindowLongPtr(hwndDlg, DWLP_USER));
  26. Assert(NULL != pWizard);
  27. #if defined (_X86_)
  28. if (IsOS(OS_ANYSERVER))
  29. #endif
  30. {
  31. // Skip over this page if we're on an x86server, or any other processor architecture.
  32. if (IDD_Main == pWizard->GetPageOrigin(IDD_ISP, NULL))
  33. {
  34. pWizard->SetPageOrigin(IDD_Internet_Connection, IDD_Main, CHK_ISP_INTERNET_CONNECTION);
  35. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
  36. // Jump to the IDD_Internet_Connection page
  37. PostMessage(GetParent(hwndDlg), PSM_SETCURSEL, 0, (LPARAM)pWizard->GetPageHandle(IDD_Internet_Connection));
  38. }
  39. else
  40. {
  41. pWizard->SetPageOrigin(IDD_Main, IDD_Internet_Connection, CHK_ISP_INTERNET_CONNECTION);
  42. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
  43. // Jump to the IDD_Main page
  44. PostMessage(GetParent(hwndDlg), PSM_SETCURSEL, 0, (LPARAM)pWizard->GetPageHandle(IDD_Main));
  45. }
  46. }
  47. return TRUE;
  48. }
  49. // ***************************************************************************
  50. // Function: OnISPDialogInit
  51. //
  52. // Purpose: Handle the WM_INITDIALOG notification
  53. //
  54. // Parameters: hwndDlg [IN] - Handle to the ISP dialog
  55. // lParam [IN] -
  56. //
  57. // Returns: BOOL
  58. // ***************************************************************************
  59. BOOL OnISPDialogInit(HWND hwndDlg, LPARAM lParam)
  60. {
  61. TraceFileFunc(ttidGuiModeSetup);
  62. INT nIdx;
  63. // The order here should be the same as the vertical order in the resources
  64. INT nrgChks[] = {CHK_ISP_OTHER_WAYS, CHK_ISP_INTERNET_CONNECTION, CHK_ISP_SOFTWARE_CD};
  65. // Initialize our pointers to property sheet info.
  66. PROPSHEETPAGE* psp = (PROPSHEETPAGE*)lParam;
  67. Assert(psp->lParam);
  68. ::SetWindowLongPtr(hwndDlg, DWLP_USER, psp->lParam);
  69. CWizard * pWizard = reinterpret_cast<CWizard *>(psp->lParam);
  70. Assert(NULL != pWizard);
  71. // Get the bold font for the radio buttons
  72. HFONT hBoldFont = NULL;
  73. SetupFonts(hwndDlg, &hBoldFont, FALSE);
  74. if (NULL != hBoldFont)
  75. {
  76. // Remember the font handle so we can free it on exit
  77. pWizard->SetPageData(IDD_ISP, (LPARAM)hBoldFont);
  78. for (nIdx = 0; nIdx < celems(nrgChks); nIdx++)
  79. {
  80. HWND hwndCtl = GetDlgItem(hwndDlg, nrgChks[nIdx]);
  81. Assert(NULL != hwndCtl);
  82. SetWindowFont(hwndCtl, hBoldFont, TRUE);
  83. }
  84. }
  85. // Find the top most enabled radio button
  86. for (nIdx = 0; nIdx < celems(nrgChks); nIdx++)
  87. {
  88. if (IsWindowEnabled(GetDlgItem(hwndDlg, nrgChks[nIdx])))
  89. {
  90. CheckRadioButton(hwndDlg, CHK_ISP_INTERNET_CONNECTION, CHK_ISP_OTHER_WAYS, nrgChks[nIdx]);
  91. break;
  92. }
  93. }
  94. return TRUE;
  95. }
  96. // ***************************************************************************
  97. // Function: OnISPWizNext
  98. //
  99. // Purpose: Handle the PSN_WIZNEXT notification
  100. //
  101. // Parameters: hwndDlg [IN] - Handle to the ISP dialog
  102. //
  103. // Returns: BOOL
  104. // ***************************************************************************
  105. BOOL OnISPWizNext(HWND hwndDlg)
  106. {
  107. TraceFileFunc(ttidGuiModeSetup);
  108. tstring str;
  109. // Retrieve the CWizard instance from the dialog
  110. CWizard * pWizard =
  111. reinterpret_cast<CWizard *>(::GetWindowLongPtr(hwndDlg, DWLP_USER));
  112. Assert(NULL != pWizard);
  113. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
  114. if ( ! IsPostInstall(pWizard) || (0 == pWizard->UlProviderCount()))
  115. {
  116. return TRUE;
  117. }
  118. if (IsDlgButtonChecked(hwndDlg, CHK_ISP_INTERNET_CONNECTION) == BST_CHECKED)
  119. {
  120. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_Internet_Connection);
  121. }
  122. else if (IsDlgButtonChecked(hwndDlg, CHK_ISP_SOFTWARE_CD) == BST_CHECKED)
  123. {
  124. pWizard->SetPageOrigin(IDD_ISPSoftwareCD, IDD_ISP, CHK_ISP_SOFTWARE_CD);
  125. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_ISPSoftwareCD);
  126. }
  127. else if (IsDlgButtonChecked(hwndDlg, CHK_ISP_OTHER_WAYS) == BST_CHECKED)
  128. {
  129. pWizard->SetPageOrigin(IDD_FinishOtherWays, IDD_ISP, CHK_ISP_OTHER_WAYS);
  130. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_FinishOtherWays);
  131. }
  132. else
  133. {
  134. AssertSz(FALSE, "What did you click on?");
  135. }
  136. return TRUE;
  137. }
  138. // ***************************************************************************
  139. // Function: dlgprocISP
  140. //
  141. // Purpose: Dialog Procedure for the ISP wizard page
  142. //
  143. // Parameters: standard dlgproc parameters
  144. //
  145. // Returns: INT_PTR
  146. // ***************************************************************************
  147. INT_PTR CALLBACK dlgprocISP(HWND hwndDlg, UINT uMsg,
  148. WPARAM wParam, LPARAM lParam)
  149. {
  150. TraceFileFunc(ttidGuiModeSetup);
  151. BOOL frt = FALSE;
  152. switch (uMsg)
  153. {
  154. case WM_INITDIALOG:
  155. frt = OnISPDialogInit(hwndDlg, lParam);
  156. break;
  157. case WM_NOTIFY:
  158. {
  159. LPNMHDR pnmh = (LPNMHDR)lParam;
  160. switch (pnmh->code)
  161. {
  162. // propsheet notification
  163. case PSN_HELP:
  164. break;
  165. case PSN_SETACTIVE:
  166. frt = OnISPPageActivate(hwndDlg);
  167. break;
  168. case PSN_APPLY:
  169. break;
  170. case PSN_KILLACTIVE:
  171. break;
  172. case PSN_RESET:
  173. break;
  174. case PSN_WIZBACK:
  175. break;
  176. case PSN_WIZFINISH:
  177. break;
  178. case PSN_WIZNEXT:
  179. frt = OnISPWizNext(hwndDlg);
  180. break;
  181. default:
  182. break;
  183. }
  184. }
  185. break;
  186. default:
  187. break;
  188. }
  189. return( frt );
  190. }
  191. // ***************************************************************************
  192. // Function: ISPPageCleanup
  193. //
  194. // Purpose: As a callback function to allow any page allocated memory
  195. // to be cleaned up, after the page will no longer be accessed.
  196. //
  197. // Parameters: pWizard [IN] - The wizard against which the page called
  198. // register page
  199. // lParam [IN] - The lParam supplied in the RegisterPage call
  200. //
  201. // Returns: nothing
  202. // ***************************************************************************
  203. VOID ISPPageCleanup(CWizard *pWizard, LPARAM lParam)
  204. {
  205. TraceFileFunc(ttidGuiModeSetup);
  206. HFONT hBoldFont = (HFONT)pWizard->GetPageData(IDD_ISP);
  207. if (NULL != hBoldFont)
  208. {
  209. DeleteObject(hBoldFont);
  210. }
  211. }
  212. // ***************************************************************************
  213. // Function: HrCreateISPPage
  214. //
  215. // Purpose: To determine if the ISP page needs to be shown, and to
  216. // to create the page if requested.
  217. //
  218. // Parameters: pWizard [IN] - Ptr to a Wizard instance
  219. // pData [IN] - Context data to describe the world in
  220. // which the Wizard will be run
  221. // fCountOnly [IN] - If True, only the maximum number of
  222. // pages this routine will create need
  223. // be determined.
  224. // pnPages [IN] - Increment by the number of pages
  225. // to create/created
  226. //
  227. // Returns: HRESULT, S_OK on success
  228. // ***************************************************************************
  229. HRESULT HrCreateISPPage(CWizard *pWizard, PINTERNAL_SETUP_DATA pData,
  230. BOOL fCountOnly, UINT *pnPages)
  231. {
  232. TraceFileFunc(ttidGuiModeSetup);
  233. HRESULT hr = S_OK;
  234. if (IsPostInstall(pWizard) && ( ! pWizard->FProcessLanPages()))
  235. {
  236. // RAS PostInstall only
  237. (*pnPages)++;
  238. // If not only counting, create and register the page
  239. if ( ! fCountOnly)
  240. {
  241. HPROPSHEETPAGE hpsp;
  242. PROPSHEETPAGE psp;
  243. TraceTag(ttidWizard, "Creating ISP Page");
  244. psp.dwSize = sizeof( PROPSHEETPAGE );
  245. psp.dwFlags = PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  246. psp.hInstance = _Module.GetResourceInstance();
  247. psp.pszTemplate = MAKEINTRESOURCE( IDD_ISP );
  248. psp.hIcon = NULL;
  249. psp.pfnDlgProc = dlgprocISP;
  250. psp.lParam = reinterpret_cast<LPARAM>(pWizard);
  251. psp.pszHeaderTitle = SzLoadIds(IDS_T_ISP);
  252. psp.pszHeaderSubTitle = SzLoadIds(IDS_ST_ISP);
  253. hpsp = CreatePropertySheetPage( &psp );
  254. if (hpsp)
  255. {
  256. pWizard->RegisterPage(IDD_ISP, hpsp,
  257. ISPPageCleanup, NULL);
  258. }
  259. else
  260. {
  261. hr = E_OUTOFMEMORY;
  262. }
  263. }
  264. }
  265. TraceHr(ttidWizard, FAL, hr, FALSE, "HrCreateISPPage");
  266. return hr;
  267. }
  268. // ***************************************************************************
  269. // Function: AppendISPPage
  270. //
  271. // Purpose: Add the ISP page, if it was created, to the set of pages
  272. // that will be displayed.
  273. //
  274. // Parameters: pWizard [IN] - Ptr to Wizard Instance
  275. // pahpsp [IN,OUT] - Array of pages to add our page to
  276. // pcPages [IN,OUT] - Count of pages in pahpsp
  277. //
  278. // Returns: Nothing
  279. // ***************************************************************************
  280. VOID AppendISPPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages)
  281. {
  282. TraceFileFunc(ttidGuiModeSetup);
  283. if (IsPostInstall(pWizard) && ( ! pWizard->FProcessLanPages()))
  284. {
  285. HPROPSHEETPAGE hPage = pWizard->GetPageHandle(IDD_ISP);
  286. Assert(hPage);
  287. pahpsp[*pcPages] = hPage;
  288. (*pcPages)++;
  289. }
  290. }
  291. // ***************************************************************************