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.

282 lines
8.4 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "resource.h"
  4. #include "wizard.h"
  5. extern CWizard * g_pSetupWizard;
  6. //
  7. // Function: OnExitPageActivate
  8. //
  9. // Purpose: Handle the PSN_SETACTIVE notification.
  10. //
  11. // Parameters: hwndDlg [IN] - Handle to the exit child dialog
  12. //
  13. // Returns: BOOL, TRUE on success
  14. //
  15. BOOL OnExitPageActivate( HWND hwndDlg )
  16. {
  17. TraceFileFunc(ttidGuiModeSetup);
  18. // Retrieve the CWizard instance from the dialog
  19. CWizard * pWizard =
  20. reinterpret_cast<CWizard *>(::GetWindowLongPtr(hwndDlg, DWLP_USER));
  21. TraceTag(ttidWizard, "Entering exit page...");
  22. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 0);
  23. // If we've past the point of no return do not allow the user to
  24. // back up from this page.
  25. if ((NULL == pWizard) || pWizard->FExitNoReturn())
  26. {
  27. // Note that this is failure handling. Either no networking answerfile
  28. // section exists or there was an error in networking setup
  29. // clean up the global object.
  30. //
  31. // Note: scottbri 19-Feb-1998
  32. //
  33. // The OC networking components need access to INetCfg but we have it locked.
  34. // On top of this it (INetCfg) has been handed off to the LAN page which has
  35. // cached it away. To free up INetCfg we need to delete g_pSetupWizard and
  36. // never allow the user to backup from this page. Ideally base setup would
  37. // call us before the OC stuff is done, but OC is implemented as pages which
  38. // follow netsetup, even though you can't back up from them.
  39. //
  40. if (pWizard && !IsPostInstall(pWizard))
  41. {
  42. ::SetWindowLongPtr(hwndDlg, DWLP_USER, 0);
  43. Assert(pWizard == g_pSetupWizard);
  44. delete g_pSetupWizard;
  45. g_pSetupWizard = NULL;
  46. }
  47. PostMessage(GetParent(hwndDlg), PSM_PRESSBUTTON, (WPARAM)(PSBTN_NEXT), 0);
  48. return TRUE;
  49. }
  50. Assert(pWizard);
  51. PAGEDIRECTION PageDir = pWizard->GetPageDirection(IDD_Exit);
  52. if (NWPD_FORWARD == PageDir)
  53. {
  54. pWizard->SetPageDirection(IDD_Exit, NWPD_BACKWARD);
  55. if (IsPostInstall(pWizard))
  56. {
  57. // Exit the wizard
  58. PropSheet_PressButton(GetParent(hwndDlg), PSBTN_FINISH);
  59. }
  60. else
  61. {
  62. //
  63. // Note: scottbri 19-Feb-1998
  64. //
  65. // The OC networking components need access to INetCfg but we have it locked.
  66. // On top of this it (INetCfg) has been handed off to the LAN page which has
  67. // cached it away. To free up INetCfg we need to delete g_pSetupWizard and
  68. // never allow the user to backup from this page. Ideally base setup would
  69. // call us before the OC stuff is done, but OC is implemented as pages which
  70. // follow netsetup, even though you can't back up from them.
  71. //
  72. if (!IsPostInstall(pWizard))
  73. {
  74. ::SetWindowLongPtr(hwndDlg, DWLP_USER, 0);
  75. Assert(pWizard == g_pSetupWizard);
  76. delete g_pSetupWizard;
  77. g_pSetupWizard = NULL;
  78. }
  79. // Goto the page after the exit page
  80. PostMessage(GetParent(hwndDlg), PSM_PRESSBUTTON, (WPARAM)(PSBTN_NEXT), 0);
  81. }
  82. }
  83. else
  84. {
  85. // Goto the page before the exit page
  86. pWizard->SetPageDirection(IDD_Exit, NWPD_FORWARD);
  87. if (IsPostInstall(pWizard))
  88. {
  89. // Main page
  90. TraceTag(ttidWizard, "Exit page to Main Page...");
  91. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_Main);
  92. }
  93. else
  94. {
  95. // try to get the join page
  96. TraceTag(ttidWizard, "Exit page to Join Page...");
  97. ::SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_Join);
  98. }
  99. }
  100. return TRUE;
  101. }
  102. //
  103. // Function: dlgprocExit
  104. //
  105. // Purpose: Dialog Procedure for the Exit wizard page
  106. //
  107. // Parameters: standard dlgproc parameters
  108. //
  109. // Returns: INT_PTR
  110. //
  111. INT_PTR CALLBACK dlgprocExit( HWND hwndDlg, UINT uMsg,
  112. WPARAM wParam, LPARAM lParam )
  113. {
  114. TraceFileFunc(ttidGuiModeSetup);
  115. BOOL frt = FALSE;
  116. switch (uMsg)
  117. {
  118. case WM_INITDIALOG:
  119. {
  120. // Initialize our pointers to property sheet info.
  121. PROPSHEETPAGE* psp = (PROPSHEETPAGE*)lParam;
  122. Assert(psp->lParam);
  123. ::SetWindowLongPtr(hwndDlg, DWLP_USER, psp->lParam);
  124. }
  125. break;
  126. case WM_NOTIFY:
  127. {
  128. LPNMHDR pnmh = (LPNMHDR)lParam;
  129. switch (pnmh->code)
  130. {
  131. // propsheet notification
  132. case PSN_HELP:
  133. break;
  134. case PSN_SETACTIVE:
  135. frt = OnExitPageActivate( hwndDlg );
  136. break;
  137. case PSN_APPLY:
  138. break;
  139. case PSN_KILLACTIVE:
  140. break;
  141. case PSN_RESET:
  142. break;
  143. case PSN_WIZBACK:
  144. break;
  145. case PSN_WIZFINISH:
  146. break;
  147. case PSN_WIZNEXT:
  148. break;
  149. default:
  150. break;
  151. }
  152. }
  153. break;
  154. default:
  155. break;
  156. }
  157. return( frt );
  158. }
  159. //
  160. // Function: ExitPageCleanup
  161. //
  162. // Purpose: As a callback function to allow any page allocated memory
  163. // to be cleaned up, after the page will no longer be accessed.
  164. //
  165. // Parameters: pWizard [IN] - The wizard against which the page called
  166. // register page
  167. // lParam [IN] - The lParam supplied in the RegisterPage call
  168. //
  169. // Returns: nothing
  170. //
  171. VOID ExitPageCleanup(CWizard *pWizard, LPARAM lParam)
  172. {
  173. TraceFileFunc(ttidGuiModeSetup);
  174. }
  175. //
  176. // Function: CreateExitPage
  177. //
  178. // Purpose: To determine if the Exit page needs to be shown, and to
  179. // to create the page if requested. Note the Exit page is
  180. // responsible for initial installs also.
  181. //
  182. // Parameters: pWizard [IN] - Ptr to a Wizard instance
  183. // pData [IN] - Context data to describe the world in
  184. // which the Wizard will be run
  185. // fCountOnly [IN] - If True, only the maximum number of
  186. // pages this routine will create need
  187. // be determined.
  188. // pnPages [IN] - Increment by the number of pages
  189. // to create/created
  190. //
  191. // Returns: HRESULT, S_OK on success
  192. //
  193. HRESULT HrCreateExitPage(CWizard *pWizard, PINTERNAL_SETUP_DATA pData,
  194. BOOL fCountOnly, UINT *pnPages)
  195. {
  196. TraceFileFunc(ttidGuiModeSetup);
  197. HRESULT hr = S_OK;
  198. (*pnPages)++;
  199. // If not only counting, create and register the page
  200. if (!fCountOnly)
  201. {
  202. HPROPSHEETPAGE hpsp;
  203. PROPSHEETPAGE psp;
  204. TraceTag(ttidWizard, "Creating Exit Page");
  205. psp.dwSize = sizeof( PROPSHEETPAGE );
  206. psp.dwFlags = 0;
  207. psp.hInstance = _Module.GetResourceInstance();
  208. psp.pszTemplate = MAKEINTRESOURCE( IDD_Exit );
  209. psp.hIcon = NULL;
  210. psp.pfnDlgProc = dlgprocExit;
  211. psp.lParam = reinterpret_cast<LPARAM>(pWizard);
  212. hpsp = CreatePropertySheetPage( &psp );
  213. if (hpsp)
  214. {
  215. pWizard->RegisterPage(IDD_Exit, hpsp,
  216. ExitPageCleanup, NULL);
  217. }
  218. else
  219. {
  220. hr = E_OUTOFMEMORY;
  221. }
  222. }
  223. TraceHr(ttidWizard, FAL, hr, FALSE, "HrCreateExitPage");
  224. return hr;
  225. }
  226. //
  227. // Function: AppendExitPage
  228. //
  229. // Purpose: Add the Exit page, if it was created, to the set of pages
  230. // that will be displayed.
  231. //
  232. // Parameters: pWizard [IN] - Ptr to Wizard Instance
  233. // pahpsp [IN,OUT] - Array of pages to add our page to
  234. // pcPages [IN,OUT] - Count of pages in pahpsp
  235. //
  236. // Returns: Nothing
  237. //
  238. VOID AppendExitPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages)
  239. {
  240. TraceFileFunc(ttidGuiModeSetup);
  241. HPROPSHEETPAGE hPage = pWizard->GetPageHandle(IDD_Exit);
  242. Assert(hPage);
  243. pahpsp[*pcPages] = hPage;
  244. (*pcPages)++;
  245. }