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.

393 lines
11 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "resource.h"
  4. #include "wizard.h"
  5. #include "ncui.h"
  6. static const UINT WM_DEFERREDINIT = WM_USER + 100;
  7. typedef struct
  8. {
  9. HFONT hBoldFont;
  10. HFONT hMarlettFont;
  11. BOOL fProcessed;
  12. } MAININTRO_DATA;
  13. //
  14. // Function: OnMainIntroPageActivate
  15. //
  16. // Purpose: Handle the PSN_SETACTIVE notification
  17. //
  18. // Parameters: hwndDlg [IN] - Handle to the MainIntro dialog
  19. //
  20. // Returns: BOOL
  21. //
  22. BOOL OnMainIntroPageActivate(HWND hwndDlg)
  23. {
  24. INT nBtn = PSWIZB_NEXT;
  25. TraceTag(ttidWizard, "Entering MainIntro Menu page...");
  26. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 0L);
  27. CWizard * pWizard =
  28. reinterpret_cast<CWizard *>(::GetWindowLongPtr(hwndDlg, DWLP_USER));
  29. if (pWizard)
  30. {
  31. MAININTRO_DATA * pData = reinterpret_cast<MAININTRO_DATA *>
  32. (pWizard->GetPageData(IDD_MainIntro));
  33. if ((pData && !pData->fProcessed) && pWizard->FDeferredProviderLoad())
  34. {
  35. nBtn = 0;
  36. }
  37. }
  38. PropSheet_SetWizButtons(GetParent(hwndDlg), nBtn);
  39. return TRUE;
  40. }
  41. //
  42. // Function: OnMainIntroDialogInit
  43. //
  44. // Purpose: Handle the WM_INITDIALOG notification
  45. //
  46. // Parameters: hwndDlg [IN] - Handle to the MainIntro dialog
  47. // lParam [IN] -
  48. //
  49. // Returns: BOOL
  50. //
  51. BOOL OnMainIntroDialogInit(HWND hwndDlg, LPARAM lParam)
  52. {
  53. // Initialize our pointers to property sheet info.
  54. PROPSHEETPAGE* psp = (PROPSHEETPAGE*)lParam;
  55. Assert(psp->lParam);
  56. ::SetWindowLongPtr(hwndDlg, DWLP_USER, psp->lParam);
  57. CWizard * pWizard = reinterpret_cast<CWizard *>(psp->lParam);
  58. Assert(NULL != pWizard);
  59. MAININTRO_DATA * pData = reinterpret_cast<MAININTRO_DATA *>
  60. (pWizard->GetPageData(IDD_MainIntro));
  61. Assert(NULL != pData);
  62. // Center the window and retain the current wizard hwnd
  63. //
  64. HWND hwndParent = GetParent(hwndDlg);
  65. CenterWizard(hwndParent);
  66. // Hide the close and context help buttons - Raid 249287
  67. long lStyle = GetWindowLong(hwndParent,GWL_STYLE);
  68. lStyle &= ~WS_SYSMENU;
  69. SetWindowLong(hwndParent,GWL_STYLE,lStyle);
  70. //
  71. // Create the Marlett font. In the Marlett font the "i" is a bullet.
  72. // Code borrowed from Add Hardware Wizard.
  73. HFONT hFontCurrent;
  74. HFONT hFontCreated;
  75. LOGFONT LogFont;
  76. hFontCurrent = (HFONT)SendMessage(GetDlgItem(hwndDlg, IDC_BULLET_1), WM_GETFONT, 0, 0);
  77. GetObject(hFontCurrent, sizeof(LogFont), &LogFont);
  78. LogFont.lfCharSet = SYMBOL_CHARSET;
  79. LogFont.lfPitchAndFamily = FF_DECORATIVE | DEFAULT_PITCH;
  80. lstrcpy(LogFont.lfFaceName, L"Marlett");
  81. hFontCreated = CreateFontIndirect(&LogFont);
  82. if (hFontCreated)
  83. {
  84. pData->hMarlettFont = hFontCreated;
  85. //
  86. // An "i" in the marlett font is a small bullet.
  87. //
  88. SetWindowText(GetDlgItem(hwndDlg, IDC_BULLET_1), L"i");
  89. SetWindowFont(GetDlgItem(hwndDlg, IDC_BULLET_1), hFontCreated, TRUE);
  90. SetWindowText(GetDlgItem(hwndDlg, IDC_BULLET_2), L"i");
  91. SetWindowFont(GetDlgItem(hwndDlg, IDC_BULLET_2), hFontCreated, TRUE);
  92. SetWindowText(GetDlgItem(hwndDlg, IDC_BULLET_3), L"i");
  93. SetWindowFont(GetDlgItem(hwndDlg, IDC_BULLET_3), hFontCreated, TRUE);
  94. }
  95. // Load the description
  96. //
  97. HFONT hBoldFont = NULL;
  98. SetupFonts(hwndDlg, &hBoldFont, TRUE);
  99. if (NULL != hBoldFont)
  100. {
  101. pData->hBoldFont = hBoldFont;
  102. HWND hwndCtl = GetDlgItem(hwndDlg, IDC_WELCOME_CAPTION);
  103. if (hwndCtl)
  104. {
  105. SetWindowFont(hwndCtl, hBoldFont, TRUE);
  106. }
  107. }
  108. if (S_OK != HrShouldHaveHomeNetWizard())
  109. {
  110. ::ShowWindow(GetDlgItem(hwndDlg, IDC_BULLET_3), SW_HIDE);
  111. ::ShowWindow(GetDlgItem(hwndDlg, TXT_CONNECTHOME), SW_HIDE);
  112. }
  113. // if the provider load was deferred until now...disable things
  114. // and let the first WM_PAINT take care of the final provider load.
  115. //
  116. if (pWizard->FDeferredProviderLoad())
  117. {
  118. PropSheet_SetWizButtons(hwndParent, 0);
  119. EnableWindow(GetDlgItem(hwndParent, IDCANCEL), FALSE);
  120. }
  121. return TRUE;
  122. }
  123. //
  124. // Function: OnMainIntroDeferredInit
  125. //
  126. // Purpose: Handle the WM_DEFERREDINIT notification
  127. //
  128. // Parameters: hwndDlg [IN] - Handle to the MainIntro dialog
  129. //
  130. // Returns: BOOL
  131. //
  132. BOOL OnMainIntroDeferredInit(HWND hwndDlg)
  133. {
  134. CWaitCursor wc;
  135. HWND hwndParent = GetParent(hwndDlg);
  136. // Retrieve the CWizard instance from the dialog
  137. CWizard * pWizard =
  138. reinterpret_cast<CWizard *>(::GetWindowLongPtr(hwndDlg, DWLP_USER));
  139. pWizard->LoadAndInsertDeferredProviderPages(hwndParent, IDD_Advanced);
  140. PropSheet_SetWizButtons(hwndParent, PSWIZB_NEXT);
  141. EnableWindow(GetDlgItem(hwndParent, IDCANCEL), TRUE);
  142. return FALSE;
  143. }
  144. //
  145. // Function: OnMainIntroPaint
  146. //
  147. // Purpose: Handle the WM_PAINT notification
  148. //
  149. // Parameters: hwndDlg [IN] - Handle to the MainIntro dialog
  150. //
  151. // Returns: BOOL
  152. //
  153. BOOL OnMainIntroPaint(HWND hwndDlg)
  154. {
  155. CWizard * pWizard =
  156. reinterpret_cast<CWizard *>(::GetWindowLongPtr(hwndDlg, DWLP_USER));
  157. MAININTRO_DATA * pData = reinterpret_cast<MAININTRO_DATA *>
  158. (pWizard->GetPageData(IDD_MainIntro));
  159. Assert(NULL != pData);
  160. if (pData && !pData->fProcessed)
  161. {
  162. pData->fProcessed = TRUE;
  163. if (pWizard->FDeferredProviderLoad())
  164. {
  165. PostMessage(hwndDlg, WM_DEFERREDINIT, 0, 0);
  166. }
  167. }
  168. return FALSE;
  169. }
  170. //
  171. // Function: dlgprocMainIntro
  172. //
  173. // Purpose: Dialog Procedure for the MainIntro wizard page
  174. //
  175. // Parameters: standard dlgproc parameters
  176. //
  177. // Returns: INT_PTR
  178. //
  179. INT_PTR CALLBACK dlgprocMainIntro(HWND hwndDlg, UINT uMsg,
  180. WPARAM wParam, LPARAM lParam)
  181. {
  182. BOOL frt = FALSE;
  183. switch (uMsg)
  184. {
  185. case WM_INITDIALOG:
  186. frt = OnMainIntroDialogInit(hwndDlg, lParam);
  187. break;
  188. case WM_DEFERREDINIT:
  189. frt = OnMainIntroDeferredInit(hwndDlg);
  190. break;
  191. case WM_PAINT:
  192. frt = OnMainIntroPaint(hwndDlg);
  193. break;
  194. case WM_NOTIFY:
  195. {
  196. LPNMHDR pnmh = (LPNMHDR)lParam;
  197. switch (pnmh->code)
  198. {
  199. // propsheet notification
  200. case PSN_HELP:
  201. break;
  202. case PSN_SETACTIVE:
  203. frt = OnMainIntroPageActivate(hwndDlg);
  204. break;
  205. case PSN_APPLY:
  206. break;
  207. case PSN_KILLACTIVE:
  208. break;
  209. case PSN_RESET:
  210. break;
  211. case PSN_WIZBACK:
  212. break;
  213. case PSN_WIZFINISH:
  214. break;
  215. case PSN_WIZNEXT:
  216. break;
  217. default:
  218. break;
  219. }
  220. }
  221. break;
  222. default:
  223. break;
  224. }
  225. return( frt );
  226. }
  227. //
  228. // Function: MainIntroPageCleanup
  229. //
  230. // Purpose: As a callback function to allow any page allocated memory
  231. // to be cleaned up, after the page will no longer be accessed.
  232. //
  233. // Parameters: pWizard [IN] - The wizard against which the page called
  234. // register page
  235. // lParam [IN] - The lParam supplied in the RegisterPage call
  236. //
  237. // Returns: nothing
  238. //
  239. VOID MainIntroPageCleanup(CWizard *pWizard, LPARAM lParam)
  240. {
  241. MAININTRO_DATA * pData = reinterpret_cast<MAININTRO_DATA *>(lParam);
  242. if (pData)
  243. {
  244. if (pData->hBoldFont)
  245. {
  246. DeleteObject(pData->hBoldFont);
  247. }
  248. if (pData->hMarlettFont)
  249. {
  250. DeleteObject(pData->hMarlettFont);
  251. }
  252. MemFree(reinterpret_cast<void*>(lParam));
  253. }
  254. }
  255. //
  256. // Function: CreateMainIntroPage
  257. //
  258. // Purpose: To determine if the MainIntro page needs to be shown, and to
  259. // to create the page if requested. Note the MainIntro page is
  260. // responsible for initial installs also.
  261. //
  262. // Parameters: pWizard [IN] - Ptr to a Wizard instance
  263. // pData [IN] - Context data to describe the world in
  264. // which the Wizard will be run
  265. // fCountOnly [IN] - If True, only the maximum number of
  266. // pages this routine will create need
  267. // be determined.
  268. // pnPages [IN] - Increment by the number of pages
  269. // to create/created
  270. //
  271. // Returns: HRESULT, S_OK on success
  272. //
  273. HRESULT HrCreateMainIntroPage(CWizard *pWizard, PINTERNAL_SETUP_DATA pData,
  274. BOOL fCountOnly, UINT *pnPages)
  275. {
  276. HRESULT hr = S_OK;
  277. if (IsPostInstall(pWizard) && !pWizard->FProcessLanPages())
  278. {
  279. // RAS PostInstall only
  280. (*pnPages)++;
  281. // If not only counting, create and register the page
  282. if (!fCountOnly)
  283. {
  284. HPROPSHEETPAGE hpsp;
  285. PROPSHEETPAGE psp;
  286. MAININTRO_DATA * pData;
  287. TraceTag(ttidWizard, "Creating MainIntro Page");
  288. psp.dwSize = sizeof( PROPSHEETPAGE );
  289. psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
  290. psp.hInstance = _Module.GetResourceInstance();
  291. psp.pszTemplate = MAKEINTRESOURCE(IDD_MainIntro);
  292. psp.hIcon = NULL;
  293. psp.pfnDlgProc = dlgprocMainIntro;
  294. psp.lParam = reinterpret_cast<LPARAM>(pWizard);
  295. hr = E_OUTOFMEMORY;
  296. pData = reinterpret_cast<MAININTRO_DATA *>(MemAlloc(sizeof(MAININTRO_DATA)));
  297. if (pData)
  298. {
  299. pData->hBoldFont = NULL;
  300. pData->hMarlettFont = NULL;
  301. pData->fProcessed = FALSE;
  302. hpsp = CreatePropertySheetPage(&psp);
  303. if (hpsp)
  304. {
  305. pWizard->RegisterPage(IDD_MainIntro, hpsp,
  306. MainIntroPageCleanup,
  307. reinterpret_cast<LPARAM>(pData));
  308. hr = S_OK;
  309. }
  310. }
  311. }
  312. }
  313. TraceHr(ttidWizard, FAL, hr, FALSE, "HrCreateMainIntroPage");
  314. return hr;
  315. }
  316. //
  317. // Function: AppendMainIntroPage
  318. //
  319. // Purpose: Add the MainIntro page, if it was created, to the set of pages
  320. // that will be displayed.
  321. //
  322. // Parameters: pWizard [IN] - Ptr to Wizard Instance
  323. // pahpsp [IN,OUT] - Array of pages to add our page to
  324. // pcPages [IN,OUT] - Count of pages in pahpsp
  325. //
  326. // Returns: Nothing
  327. //
  328. VOID AppendMainIntroPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages)
  329. {
  330. if (IsPostInstall(pWizard) && !pWizard->FProcessLanPages())
  331. {
  332. HPROPSHEETPAGE hPage = pWizard->GetPageHandle(IDD_MainIntro);
  333. Assert(hPage);
  334. pahpsp[*pcPages] = hPage;
  335. (*pcPages)++;
  336. }
  337. }