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.

266 lines
7.4 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: Wizpage.cpp
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: KeisukeT
  10. *
  11. * DATE: 27 Mar, 2000
  12. *
  13. * DESCRIPTION:
  14. * Generic wizard page class. This is parent class of each wizard pages and it
  15. * handles common user operation of wizard.
  16. *
  17. *******************************************************************************/
  18. //
  19. // Precompiled header
  20. //
  21. #include "precomp.h"
  22. #pragma hdrstop
  23. //
  24. // Include
  25. //
  26. #include "wizpage.h"
  27. #include <stilib.h>
  28. //
  29. // Extern
  30. //
  31. extern HINSTANCE g_hDllInstance;
  32. //
  33. // Function
  34. //
  35. INT_PTR
  36. CALLBACK
  37. CInstallWizardPage::PageProc(
  38. HWND hwndPage,
  39. UINT uiMessage,
  40. WPARAM wParam,
  41. LPARAM lParam
  42. )
  43. {
  44. INT_PTR ipReturn = 0;
  45. // DebugTrace(TRACE_PROC_ENTER,(("CInstallWizardPage::PageProc: Enter... \r\n")));
  46. //
  47. // Get current context.
  48. //
  49. CInstallWizardPage *pInstallWizardPage = (CInstallWizardPage *)GetWindowLongPtr(hwndPage, DWLP_USER);
  50. switch (uiMessage) {
  51. case WM_INITDIALOG: {
  52. LPPROPSHEETPAGE pPropSheetPage;
  53. // The lParam will point to the PROPSHEETPAGE structure which
  54. // created this page. Its lParam parameter will point to the
  55. // object instance.
  56. pPropSheetPage = (LPPROPSHEETPAGE) lParam;
  57. pInstallWizardPage = (CInstallWizardPage *) pPropSheetPage->lParam;
  58. ::SetWindowLongPtr(hwndPage, DWLP_USER, (LONG_PTR)pInstallWizardPage);
  59. //
  60. // Save parent windows handle.
  61. //
  62. pInstallWizardPage->m_hwnd = hwndPage;
  63. //
  64. // Call derived class.
  65. //
  66. ipReturn = pInstallWizardPage->OnInit();
  67. goto PageProc_return;
  68. break;
  69. } // case WM_INITDIALOG:
  70. case WM_COMMAND:
  71. {
  72. //
  73. // Just pass down to the derived class.
  74. //
  75. ipReturn = pInstallWizardPage->OnCommand(LOWORD(wParam), HIWORD(wParam), (HWND) LOWORD(lParam));
  76. goto PageProc_return;
  77. break;
  78. } // case WM_COMMAND:
  79. case WM_NOTIFY:
  80. {
  81. LPNMHDR lpnmh = (LPNMHDR) lParam;
  82. //
  83. // Let derivd class handle this first, then we do if it returns FALSE.
  84. //
  85. ipReturn = pInstallWizardPage->OnNotify(lpnmh);
  86. if(FALSE == ipReturn){
  87. DebugTrace(TRACE_STATUS,(("CInstallWizardPage::PageProc: Processing default WM_NOTIFY handler. \r\n")));
  88. switch (lpnmh->code) {
  89. case PSN_WIZBACK:
  90. pInstallWizardPage->m_bNextButtonPushed = FALSE;
  91. //
  92. // Goto previous page.
  93. //
  94. ::SetWindowLongPtr(hwndPage, DWLP_MSGRESULT, (LONG_PTR)pInstallWizardPage->m_uPreviousPage);
  95. ipReturn = TRUE;
  96. goto PageProc_return;
  97. case PSN_WIZNEXT:
  98. pInstallWizardPage->m_bNextButtonPushed = TRUE;
  99. //
  100. // Goto next page.
  101. //
  102. ::SetWindowLongPtr(hwndPage, DWLP_MSGRESULT, (LONG_PTR)pInstallWizardPage->m_uNextPage);
  103. ipReturn = TRUE;
  104. goto PageProc_return;
  105. case PSN_SETACTIVE: {
  106. DWORD dwFlags;
  107. //
  108. // Set the wizard buttons, according to next/prev page.
  109. //
  110. dwFlags =
  111. (pInstallWizardPage->m_uPreviousPage ? PSWIZB_BACK : 0)
  112. | (pInstallWizardPage->m_uNextPage ? PSWIZB_NEXT : PSWIZB_FINISH);
  113. ::SendMessage(GetParent(hwndPage),
  114. PSM_SETWIZBUTTONS,
  115. 0,
  116. (long) dwFlags);
  117. ipReturn = TRUE;
  118. goto PageProc_return;
  119. } // case PSN_SETACTIVE:
  120. case PSN_QUERYCANCEL: {
  121. //
  122. // User canceled. Free device object if ever allocated.
  123. //
  124. if(NULL != pInstallWizardPage->m_pCDevice){
  125. delete pInstallWizardPage->m_pCDevice;
  126. pInstallWizardPage->m_pCDevice = NULL;
  127. } // if(NULL != m_pCDevice)
  128. ipReturn = TRUE;
  129. goto PageProc_return;
  130. } // case PSN_QUERYCANCEL:
  131. } // switch (lpnmh->code)
  132. ipReturn = TRUE;;
  133. } // if(FALSE == ipReturn)
  134. goto PageProc_return;
  135. break;
  136. } // case WM_NOTIFY:
  137. default:
  138. ipReturn = FALSE;
  139. } // switch (uiMessage)
  140. PageProc_return:
  141. // DebugTrace(TRACE_PROC_LEAVE,(("CInstallWizardPage::PageProc: Leaving... Ret=0x%x.\r\n"), ipReturn));
  142. return ipReturn;
  143. }
  144. CInstallWizardPage::CInstallWizardPage(
  145. PINSTALLER_CONTEXT pInstallerContext,
  146. UINT uTemplate
  147. )
  148. {
  149. //
  150. // Initialize property sheet.
  151. //
  152. m_PropSheetPage.hInstance = g_hDllInstance;
  153. m_PropSheetPage.pszTemplate = MAKEINTRESOURCE(uTemplate);
  154. m_PropSheetPage.pszTitle = MAKEINTRESOURCE(MessageTitle);
  155. m_PropSheetPage.dwSize = sizeof m_PropSheetPage;
  156. m_PropSheetPage.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  157. m_PropSheetPage.pfnDlgProc = PageProc;
  158. m_PropSheetPage.lParam = (LPARAM) this;
  159. m_PropSheetPage.pszHeaderTitle = MAKEINTRESOURCE(HeaderTitle);
  160. m_PropSheetPage.pszHeaderSubTitle = MAKEINTRESOURCE(SubHeaderTitle);
  161. //
  162. // Don't want to show header on welcome/final page.
  163. //
  164. if( (IDD_DYNAWIZ_FIRSTPAGE == uTemplate)
  165. || (EmeraldCity == uTemplate) )
  166. {
  167. m_PropSheetPage.dwFlags |= PSP_HIDEHEADER;
  168. }
  169. //
  170. // We want to show some other header for some pages.
  171. //
  172. if(IDD_DYNAWIZ_SELECT_NEXTPAGE == uTemplate){
  173. m_PropSheetPage.pszHeaderTitle = MAKEINTRESOURCE(HeaderForPortsel);
  174. } else if (NameTheDevice == uTemplate) {
  175. m_PropSheetPage.pszHeaderTitle = MAKEINTRESOURCE(HeaderForNameIt);
  176. }
  177. //
  178. // Add the Fusion flags and global context, so the pages we add will pick up COMCTL32V6
  179. //
  180. m_PropSheetPage.hActCtx = g_hActCtx;
  181. m_PropSheetPage.dwFlags |= PSP_USEFUSIONCONTEXT;
  182. //
  183. // Create Property sheet page.
  184. //
  185. m_hPropSheetPage = CreatePropertySheetPage(&m_PropSheetPage);
  186. //
  187. // Set other member.
  188. //
  189. m_hwnd = NULL;
  190. m_hwndWizard = pInstallerContext->hwndWizard;
  191. m_pCDevice = NULL;
  192. m_bNextButtonPushed = TRUE;
  193. }
  194. CInstallWizardPage::~CInstallWizardPage(
  195. VOID
  196. )
  197. {
  198. //
  199. // Destroy property sheet page.
  200. //
  201. if(NULL != m_hPropSheetPage){
  202. m_hPropSheetPage = NULL;
  203. }
  204. }