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.

385 lines
9.9 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. wizard.c
  5. Abstract:
  6. Routines to run the wizard for the suite.
  7. Author:
  8. Ted Miller (tedm) 1-Oct-1996
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. HPROPSHEETPAGE
  14. CreateInstallationAndProgressPage(
  15. VOID
  16. );
  17. INT_PTR
  18. FinalPageDlgProc(
  19. IN HWND hdlg,
  20. IN UINT msg,
  21. IN WPARAM wParam,
  22. IN LPARAM lParam
  23. );
  24. //
  25. // Bogus global variable necessary because there's no way to get
  26. // a value through to the PropSheetCallback.
  27. //
  28. PVOID _CBx;
  29. int
  30. CALLBACK
  31. PropSheetCallback(
  32. IN HWND DialogHandle,
  33. IN UINT msg,
  34. IN LPARAM lparam
  35. )
  36. {
  37. DWORD oldp;
  38. LPDLGTEMPLATE dtemplate;
  39. switch (msg) {
  40. case PSCB_PRECREATE:
  41. dtemplate = (LPDLGTEMPLATE)lparam;
  42. if (QuietMode) {
  43. VirtualProtect(dtemplate, sizeof(DLGTEMPLATE), PAGE_READWRITE, &oldp);
  44. dtemplate->style = dtemplate->style & ~WS_VISIBLE;
  45. }
  46. break;
  47. case PSCB_INITIALIZED:
  48. OcRememberWizardDialogHandle(_CBx,DialogHandle);
  49. break;
  50. }
  51. return 0;
  52. }
  53. BOOL
  54. DoWizard(
  55. IN PVOID OcManagerContext,
  56. IN HWND StartingMsgWindow,
  57. IN HCURSOR hOldCursor
  58. )
  59. /*++
  60. Routine Description:
  61. This routine creates and displays the wizard.
  62. Arguments:
  63. OcManagerContext - value returned from OcInitialize().
  64. Return Value:
  65. Boolean value indicating whether the wizard was successfully displayed.
  66. --*/
  67. {
  68. PSETUP_REQUEST_PAGES PagesFromOcManager[WizPagesTypeMax];
  69. BOOL b;
  70. UINT u;
  71. UINT PageCount;
  72. UINT i;
  73. HPROPSHEETPAGE *PageHandles;
  74. HPROPSHEETPAGE OcPage = NULL;
  75. HPROPSHEETPAGE SetupPage;
  76. HPROPSHEETPAGE FinalPage;
  77. PROPSHEETPAGE PageDescrip;
  78. PROPSHEETHEADER PropSheet;
  79. OC_PAGE_CONTROLS WizardPageControlsInfo;
  80. OC_PAGE_CONTROLS DetailsPageControlsInfo;
  81. SETUP_PAGE_CONTROLS SetupPageControlsInfo;
  82. HDC hdc;
  83. HWND PsHwnd;
  84. b = FALSE;
  85. u = OcGetWizardPages(OcManagerContext,PagesFromOcManager);
  86. if(u != NO_ERROR) {
  87. MessageBoxFromMessageAndSystemError(
  88. NULL,
  89. MSG_CANT_INIT,
  90. u,
  91. MAKEINTRESOURCE(AppTitleStringId),
  92. MB_OK | MB_ICONERROR | MB_SYSTEMMODAL | MB_SETFOREGROUND
  93. );
  94. goto c0;
  95. }
  96. //
  97. // There must be a final page, because the final page comes right after the
  98. // setup page, and we don't want the setup page to have to know whether to
  99. // simulate pressing next or finish to advance.
  100. //
  101. if(!PagesFromOcManager[WizPagesFinal] || !PagesFromOcManager[WizPagesFinal]->MaxPages) {
  102. PageDescrip.dwSize = sizeof(PROPSHEETPAGE);
  103. PageDescrip.dwFlags = PSP_DEFAULT;
  104. PageDescrip.hInstance = hInst;
  105. PageDescrip.pszTemplate = MAKEINTRESOURCE(IDD_FINAL);
  106. PageDescrip.pfnDlgProc = FinalPageDlgProc;
  107. FinalPage = CreatePropertySheetPage(&PageDescrip);
  108. if(!FinalPage) {
  109. MessageBoxFromMessageAndSystemError(
  110. NULL,
  111. MSG_CANT_INIT,
  112. ERROR_NOT_ENOUGH_MEMORY,
  113. MAKEINTRESOURCE(AppTitleStringId),
  114. MB_OK | MB_ICONERROR | MB_SYSTEMMODAL | MB_SETFOREGROUND
  115. );
  116. goto c1;
  117. }
  118. } else {
  119. FinalPage = NULL;
  120. }
  121. //
  122. // Calculate the number of pages. There's two extra pages (the OC and setup pages).
  123. // Also leave room for a potential dummy final page.
  124. //
  125. PageCount = FinalPage ? 3 : 2;
  126. for(u=0; u<WizPagesTypeMax; u++) {
  127. if(PagesFromOcManager[u]) {
  128. PageCount += PagesFromOcManager[u]->MaxPages;
  129. }
  130. }
  131. //
  132. // Allocate space for the page structures.
  133. //
  134. PageHandles = MyMalloc(PageCount * sizeof(HPROPSHEETPAGE));
  135. if(!PageHandles) {
  136. MessageBoxFromMessageAndSystemError(
  137. NULL,
  138. MSG_CANT_INIT,
  139. ERROR_NOT_ENOUGH_MEMORY,
  140. MAKEINTRESOURCE(AppTitleStringId),
  141. MB_OK | MB_ICONERROR | MB_SYSTEMMODAL | MB_SETFOREGROUND
  142. );
  143. goto c1;
  144. }
  145. ZeroMemory(PageHandles,PageCount*sizeof(HPROPSHEETPAGE));
  146. //
  147. // Create the OC Page.
  148. //
  149. WizardPageControlsInfo.TemplateModule = hInst;
  150. WizardPageControlsInfo.TemplateResource = MAKEINTRESOURCE(IDD_OC_WIZARD_PAGE);
  151. WizardPageControlsInfo.ListBox = IDC_LISTBOX;
  152. WizardPageControlsInfo.TipText = IDT_TIP;
  153. WizardPageControlsInfo.DetailsButton = IDB_DETAILS;
  154. WizardPageControlsInfo.ResetButton = IDB_RESET;
  155. WizardPageControlsInfo.InstalledCountText = IDT_INSTALLED_COUNT;
  156. WizardPageControlsInfo.SpaceNeededText = IDT_SPACE_NEEDED_NUM;
  157. WizardPageControlsInfo.SpaceAvailableText = IDT_SPACE_AVAIL_NUM;
  158. WizardPageControlsInfo.InstructionsText = IDT_INSTRUCTIONS;
  159. WizardPageControlsInfo.HeaderText = IDS_OCPAGE_HEADER;
  160. WizardPageControlsInfo.SubheaderText = IDS_OCPAGE_SUBHEAD;
  161. WizardPageControlsInfo.ComponentHeaderText = IDT_COMP_TITLE;
  162. DetailsPageControlsInfo = WizardPageControlsInfo;
  163. DetailsPageControlsInfo.TemplateResource = MAKEINTRESOURCE(IDD_OC_DETAILS_PAGE);
  164. if (OcSubComponentsPresent(OcManagerContext)) {
  165. OcPage = OcCreateOcPage(OcManagerContext,&WizardPageControlsInfo,&DetailsPageControlsInfo);
  166. if(!OcPage) {
  167. MessageBoxFromMessageAndSystemError(
  168. NULL,
  169. MSG_CANT_INIT,
  170. ERROR_NOT_ENOUGH_MEMORY,
  171. MAKEINTRESOURCE(AppTitleStringId),
  172. MB_OK | MB_ICONERROR | MB_SYSTEMMODAL | MB_SETFOREGROUND
  173. );
  174. goto c2;
  175. }
  176. }
  177. SetupPageControlsInfo.TemplateModule = hInst;
  178. SetupPageControlsInfo.TemplateResource = MAKEINTRESOURCE(IDD_PROGRESS_PAGE);
  179. SetupPageControlsInfo.ProgressBar = IDC_PROGRESS;
  180. SetupPageControlsInfo.ProgressLabel = IDT_THERM_LABEL;
  181. SetupPageControlsInfo.ProgressText = IDT_TIP;
  182. SetupPageControlsInfo.AnimationControl = IDA_EXTERNAL_PROGRAM;
  183. SetupPageControlsInfo.AnimationResource = IDA_FILECOPY;
  184. SetupPageControlsInfo.ForceExternalProgressIndicator = ForceExternalProgressIndicator;
  185. SetupPageControlsInfo.AllowCancel = AllowCancel;
  186. SetupPageControlsInfo.HeaderText = IDS_PROGPAGE_HEADER;
  187. SetupPageControlsInfo.SubheaderText = IDS_PROGPAGE_SUBHEAD;
  188. SetupPage = OcCreateSetupPage(OcManagerContext,&SetupPageControlsInfo);
  189. if(!SetupPage) {
  190. MessageBoxFromMessageAndSystemError(
  191. NULL,
  192. MSG_CANT_INIT,
  193. ERROR_NOT_ENOUGH_MEMORY,
  194. MAKEINTRESOURCE(AppTitleStringId),
  195. MB_OK | MB_ICONERROR | MB_SYSTEMMODAL | MB_SETFOREGROUND
  196. );
  197. goto c2;
  198. }
  199. for(PageCount=0,u=0; u<WizPagesTypeMax; u++) {
  200. //
  201. // OC Page comes between mode and early pages.
  202. // Setup page comes right before final page.
  203. //
  204. if(u == WizPagesEarly && OcPage) {
  205. PageHandles[PageCount++] = OcPage;
  206. } else {
  207. if(u == WizPagesFinal) {
  208. PageHandles[PageCount++] = SetupPage;
  209. if(FinalPage) {
  210. PageHandles[PageCount++] = FinalPage;
  211. }
  212. }
  213. }
  214. if(PagesFromOcManager[u]) {
  215. CopyMemory(
  216. PageHandles+PageCount,
  217. PagesFromOcManager[u]->Pages,
  218. PagesFromOcManager[u]->MaxPages * sizeof(HPROPSHEETPAGE)
  219. );
  220. PageCount += PagesFromOcManager[u]->MaxPages;
  221. }
  222. }
  223. //
  224. // OK, we're ready. Set up and go.
  225. //
  226. PropSheet.dwSize = sizeof(PROPSHEETHEADER);
  227. PropSheet.dwFlags = PSH_WIZARD | PSH_USECALLBACK | PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
  228. PropSheet.hwndParent = NULL;
  229. PropSheet.hInstance = hInst;
  230. PropSheet.nPages = PageCount;
  231. PropSheet.nStartPage = 0;
  232. PropSheet.phpage = PageHandles;
  233. PropSheet.pfnCallback = PropSheetCallback;
  234. PropSheet.pszbmHeader = MAKEINTRESOURCE(IDB_WATERMARK1_16);
  235. PropSheet.pszbmWatermark = MAKEINTRESOURCE(IDB_WELCOME);
  236. if(hdc = GetDC(NULL)) {
  237. if(GetDeviceCaps(hdc,BITSPIXEL) >= 8) {
  238. PropSheet.pszbmHeader = MAKEINTRESOURCE(IDB_WATERMARK1_256);
  239. }
  240. ReleaseDC(NULL,hdc);
  241. }
  242. //
  243. // Bogus global var used because we need to get a value through to
  244. // the property sheet callback routine.
  245. //
  246. _CBx = OcManagerContext;
  247. // make sure our new window can hold the focus before killing the wait window
  248. if(StartingMsgWindow) {
  249. AllowSetForegroundWindow(GetCurrentProcessId());
  250. PostMessage(StartingMsgWindow,WM_APP,0,0);
  251. }
  252. SetCursor(hOldCursor);
  253. PsHwnd = (HWND) PropertySheet( &PropSheet );
  254. if((LONG_PTR)PsHwnd == -1) {
  255. MessageBoxFromMessageAndSystemError(
  256. NULL,
  257. MSG_CANT_INIT,
  258. ERROR_NOT_ENOUGH_MEMORY,
  259. MAKEINTRESOURCE(AppTitleStringId),
  260. MB_OK | MB_ICONERROR | MB_SYSTEMMODAL | MB_SETFOREGROUND
  261. );
  262. } else {
  263. b = TRUE;
  264. }
  265. c2:
  266. MyFree(PageHandles);
  267. c1:
  268. for(u=0; u<WizPagesTypeMax; u++) {
  269. if (PagesFromOcManager[u]) {
  270. pSetupFree(PagesFromOcManager[u]);
  271. }
  272. }
  273. c0:
  274. return(b);
  275. }
  276. INT_PTR
  277. FinalPageDlgProc(
  278. IN HWND hdlg,
  279. IN UINT msg,
  280. IN WPARAM wParam,
  281. IN LPARAM lParam
  282. )
  283. {
  284. BOOL b;
  285. NMHDR *NotifyParams;
  286. b = FALSE;
  287. switch(msg) {
  288. case WM_NOTIFY:
  289. NotifyParams = (NMHDR *)lParam;
  290. switch(NotifyParams->code) {
  291. case PSN_SETACTIVE:
  292. // We don't dispaly this page. Just use it to end the Wizard set
  293. PropSheet_SetWizButtons(GetParent(hdlg),PSWIZB_FINISH);
  294. PropSheet_PressButton(GetParent(hdlg),PSBTN_FINISH);
  295. // fall through
  296. case PSN_KILLACTIVE:
  297. case PSN_WIZBACK:
  298. case PSN_WIZNEXT:
  299. case PSN_WIZFINISH:
  300. //
  301. // Allow activation/motion.
  302. //
  303. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,0);
  304. b = TRUE;
  305. break;
  306. }
  307. }
  308. return(b);
  309. }