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.

259 lines
7.3 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "pch.hxx"
  4. #include "wizard.h"
  5. //
  6. // Function: OnModeWizBackNext
  7. //
  8. // Purpose: Handle the PSN_WIZ notification.
  9. //
  10. // Parameters: hwndDlg [IN] - Handle to the exit child dialog
  11. //
  12. // Returns: BOOL, TRUE on success
  13. //
  14. BOOL OnModeWizBackNext(HWND hwndDlg)
  15. {
  16. HPROPSHEETPAGE hPage = NULL;
  17. // Retrieve the CWizard instance from the dialog
  18. LPARAM lParam = GetWindowLong(hwndDlg, DWL_USER);
  19. CWizard * pWizard = reinterpret_cast<CWizard *>(lParam);
  20. Assert(NULL != pWizard);
  21. PAGEDIRECTION PageDir = pWizard->GetPageDirection(IDD_Mode);
  22. if (NWPD_FORWARD == PageDir)
  23. {
  24. if (IsDlgButtonChecked(hwndDlg, CHK_MODE_TYPICAL))
  25. {
  26. pWizard->ChangeSetupMode(NCWUC_SETUPMODE_TYPICAL);
  27. // Goto the Join page if not postinstall
  28. hPage = pWizard->GetPageHandle(IDD_Join);
  29. }
  30. else
  31. {
  32. HRESULT hr = S_OK;
  33. pWizard->ChangeSetupMode(NCWUC_SETUPMODE_CUSTOM);
  34. pWizard->SetCurrentProvider(0);
  35. CWizProvider * pWizProvider = pWizard->GetCurrentProvider();
  36. Assert(NULL != pWizProvider);
  37. Assert(pWizProvider->ULPageCount());
  38. // Push the adapter guid onto the provider
  39. hr = pWizProvider->HrSpecifyAdapterGuid(
  40. pWizard->GetCurrentAdapterGuid());
  41. // Goto the first page of the appropriate provider
  42. pWizard->SetPageDirection(IDD_Mode, NWPD_BACKWARD);
  43. CWizProvider * pWizProvider = pWizard->GetCurrentProvider();
  44. Assert(NULL != pWizProvider);
  45. Assert(0 < pWizProvider->ULPageCount());
  46. hPage = (pWizProvider->PHPropPages())[0];
  47. }
  48. }
  49. else
  50. {
  51. // Back from here is wwelcome when postinstall
  52. // and wupgrade when not postinstall
  53. pWizard->SetPageDirection(IDD_Mode, NWPD_FORWARD);
  54. return FALSE; // Let the default occur
  55. }
  56. Assert(hPage);
  57. SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
  58. PostMessage(GetParent(hwndDlg), PSM_SETCURSEL, 0,
  59. (LPARAM)(HPROPSHEETPAGE)hPage);
  60. return TRUE; // The PostMessage will do the work
  61. }
  62. //
  63. // Function: dlgprocMode
  64. //
  65. // Purpose: Dialog Procedure for the Mode wizard page
  66. //
  67. // Parameters: standard dlgproc parameters
  68. //
  69. // Returns: INT_PTR
  70. //
  71. INT_PTR CALLBACK dlgprocMode( HWND hwndDlg, UINT uMsg,
  72. WPARAM wParam, LPARAM lParam )
  73. {
  74. BOOL frt = FALSE;
  75. switch (uMsg)
  76. {
  77. case WM_INITDIALOG:
  78. {
  79. // Initialize our pointers to property sheet info.
  80. PROPSHEETPAGE* psp = (PROPSHEETPAGE*)lParam;
  81. Assert(psp->lParam);
  82. SetWindowLong(hwndDlg, DWL_USER, psp->lParam);
  83. tstring str = SzLoadIds(IDS_TXT_MODE_DESC_1);
  84. str += SzLoadIds(IDS_TXT_MODE_DESC_2);
  85. SetWindowText(GetDlgItem(hwndDlg, TXT_MODE_DESC), str.c_str());
  86. CWizard * pWizard = reinterpret_cast<CWizard *>(psp->lParam);
  87. Assert(NULL != pWizard);
  88. CWizardUiContext * pCtx = pWizard->GetUiContext();
  89. Assert(NULL != pCtx);
  90. int idc = ((pCtx->GetSetupMode() & SETUPMODE_TYPICAL) ?
  91. CHK_MODE_TYPICAL : CHK_MODE_CUSTOM);
  92. CheckRadioButton(hwndDlg, CHK_MODE_TYPICAL,
  93. CHK_MODE_CUSTOM, idc);
  94. }
  95. break;
  96. case WM_NOTIFY:
  97. {
  98. LPNMHDR pnmh = (LPNMHDR)lParam;
  99. switch (pnmh->code)
  100. {
  101. // propsheet notification
  102. case PSN_HELP:
  103. break;
  104. case PSN_SETACTIVE:
  105. TraceTag(ttidWizard, "Entering Mode page...");
  106. break;
  107. case PSN_APPLY:
  108. break;
  109. case PSN_KILLACTIVE:
  110. break;
  111. case PSN_RESET:
  112. break;
  113. case PSN_WIZBACK:
  114. frt = OnModeWizBackNext(hwndDlg);
  115. break;
  116. case PSN_WIZFINISH:
  117. break;
  118. case PSN_WIZNEXT:
  119. frt = OnModeWizBackNext(hwndDlg);
  120. break;
  121. default:
  122. break;
  123. }
  124. }
  125. break;
  126. default:
  127. break;
  128. }
  129. return( frt );
  130. }
  131. //
  132. // Function: ModePageCleanup
  133. //
  134. // Purpose: As a callback function to allow any page allocated memory
  135. // to be cleaned up, after the page will no longer be accessed.
  136. //
  137. // Parameters: pWizard [IN] - The wizard against which the page called
  138. // register page
  139. // lParam [IN] - The lParam supplied in the RegisterPage call
  140. //
  141. // Returns: nothing
  142. //
  143. VOID ModePageCleanup(CWizard *pWizard, LPARAM lParam)
  144. {
  145. }
  146. //
  147. // Function: CreateModePage
  148. //
  149. // Purpose: To determine if the Mode page needs to be shown, and to
  150. // to create the page if requested. Note the Mode page is
  151. // responsible for initial installs also.
  152. //
  153. // Parameters: pWizard [IN] - Ptr to a Wizard instance
  154. // pData [IN] - Context data to describe the world in
  155. // which the Wizard will be run
  156. // fCountOnly [IN] - If True, only the maximum number of
  157. // pages this routine will create need
  158. // be determined.
  159. // pnPages [IN] - Increment by the number of pages
  160. // to create/created
  161. //
  162. // Returns: HRESULT, S_OK on success
  163. //
  164. HRESULT HrCreateModePage(CWizard *pWizard, PINTERNAL_SETUP_DATA pData,
  165. BOOL fCountOnly, UINT *pnPages)
  166. {
  167. HRESULT hr = S_OK;
  168. // Batch Mode or for fresh install
  169. if (pWizard->FProcessLanPages())
  170. {
  171. (*pnPages)++;
  172. // If not only counting, create and register the page
  173. if (!fCountOnly)
  174. {
  175. HPROPSHEETPAGE hpsp;
  176. PROPSHEETPAGE psp;
  177. TraceTag(ttidWizard, "Creating Mode Page");
  178. psp.dwSize = sizeof( PROPSHEETPAGE );
  179. psp.dwFlags = 0;
  180. psp.hInstance = _Module.GetResourceInstance();
  181. psp.pszTemplate = MAKEINTRESOURCE( IDD_Mode );
  182. psp.hIcon = NULL;
  183. psp.pfnDlgProc = dlgprocMode;
  184. psp.lParam = reinterpret_cast<LPARAM>(pWizard);
  185. hpsp = CreatePropertySheetPage( &psp );
  186. if (hpsp)
  187. {
  188. pWizard->RegisterPage(IDD_Mode, hpsp,
  189. ModePageCleanup, NULL);
  190. }
  191. else
  192. {
  193. hr = E_OUTOFMEMORY;
  194. }
  195. }
  196. }
  197. TraceHr(ttidWizard, FAL, hr, FALSE, "HrCreateModePage");
  198. return hr;
  199. }
  200. //
  201. // Function: AppendModePage
  202. //
  203. // Purpose: Add the Mode page, if it was created, to the set of pages
  204. // that will be displayed.
  205. //
  206. // Parameters: pWizard [IN] - Ptr to Wizard Instance
  207. // pahpsp [IN,OUT] - Array of pages to add our page to
  208. // pcPages [IN,OUT] - Count of pages in pahpsp
  209. //
  210. // Returns: Nothing
  211. //
  212. VOID AppendModePage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages)
  213. {
  214. if (pWizard->FProcessLanPages())
  215. {
  216. HPROPSHEETPAGE hPage = pWizard->GetPageHandle(IDD_Mode);
  217. Assert(hPage);
  218. pahpsp[*pcPages] = hPage;
  219. (*pcPages)++;
  220. }
  221. }