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.

222 lines
4.2 KiB

  1. /*
  2. * Copyright (c) 1998 Microsoft Corporation
  3. *
  4. * Module Name:
  5. *
  6. * ocpage.cpp
  7. *
  8. * Abstract:
  9. *
  10. * This file defines an OC Manager Wizard Page base class.
  11. *
  12. * Author:
  13. *
  14. * Breen Hagan (BreenH) Oct-02-98
  15. *
  16. * Environment:
  17. *
  18. * User Mode
  19. */
  20. #include "stdafx.h"
  21. #include "logfile.h"
  22. /*
  23. * External Function Prototypes.
  24. */
  25. HINSTANCE GetInstance();
  26. INT_PTR CALLBACK
  27. OCPage::PropertyPageDlgProc(
  28. HWND hwndDlg,
  29. UINT uMsg,
  30. WPARAM wParam,
  31. LPARAM lParam
  32. )
  33. {
  34. OCPage *pDlg;
  35. if (uMsg == WM_INITDIALOG) {
  36. pDlg = reinterpret_cast<OCPage*>(LPPROPSHEETPAGE(lParam)->lParam);
  37. } else {
  38. pDlg = reinterpret_cast<OCPage*>(GetWindowLongPtr(hwndDlg, DWLP_USER));
  39. }
  40. if (pDlg == NULL) {
  41. return(0);
  42. }
  43. switch(uMsg) {
  44. case WM_INITDIALOG:
  45. pDlg->SetDlgWnd(hwndDlg);
  46. SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pDlg);
  47. return(pDlg->OnInitDialog(hwndDlg, wParam, lParam));
  48. case WM_NOTIFY:
  49. return(pDlg->OnNotify(hwndDlg, wParam, lParam));
  50. case WM_COMMAND:
  51. return(pDlg->OnCommand(hwndDlg, wParam, lParam));
  52. }
  53. return(0);
  54. }
  55. OCPage::OCPage ()
  56. {
  57. }
  58. BOOL OCPage::Initialize ()
  59. {
  60. dwFlags = PSP_USECALLBACK;
  61. pszHeaderTitle = MAKEINTRESOURCE(GetHeaderTitleResource());
  62. if (pszHeaderTitle) {
  63. dwFlags |= PSP_USEHEADERTITLE;
  64. }
  65. pszHeaderSubTitle = MAKEINTRESOURCE(GetHeaderSubTitleResource());
  66. if (pszHeaderSubTitle) {
  67. dwFlags |= PSP_USEHEADERSUBTITLE;
  68. }
  69. dwSize = sizeof(PROPSHEETPAGE);
  70. hInstance = GetInstance();
  71. pszTemplate = MAKEINTRESOURCE(GetPageID());
  72. pfnDlgProc = PropertyPageDlgProc;
  73. pfnCallback = NULL;
  74. lParam = (LPARAM)this;
  75. return(pszTemplate != NULL ? TRUE : FALSE);
  76. }
  77. OCPage::~OCPage()
  78. {
  79. }
  80. BOOL
  81. OCPage::OnNotify(
  82. HWND hWndDlg,
  83. WPARAM wParam,
  84. LPARAM lParam
  85. )
  86. {
  87. NMHDR *pnmh = (LPNMHDR) lParam;
  88. switch(pnmh->code)
  89. {
  90. case PSN_SETACTIVE:
  91. SetWindowLongPtr(hWndDlg, DWLP_MSGRESULT, CanShow() ? 0 : -1);
  92. PropSheet_SetWizButtons(GetParent(hWndDlg),
  93. PSWIZB_NEXT | PSWIZB_BACK);
  94. break;
  95. case PSN_WIZNEXT:
  96. SetWindowLongPtr(hWndDlg, DWLP_MSGRESULT, ApplyChanges() ? 0 : -1);
  97. break;
  98. case PSN_WIZBACK:
  99. SetWindowLongPtr(hWndDlg, DWLP_MSGRESULT, 0);
  100. break;
  101. default:
  102. return(FALSE);
  103. }
  104. UNREFERENCED_PARAMETER(lParam);
  105. UNREFERENCED_PARAMETER(wParam);
  106. return(TRUE);
  107. }
  108. BOOL
  109. OCPage::OnCommand(
  110. HWND hWndDlg,
  111. WPARAM wParam,
  112. LPARAM lParam
  113. )
  114. {
  115. UNREFERENCED_PARAMETER(lParam);
  116. UNREFERENCED_PARAMETER(wParam);
  117. UNREFERENCED_PARAMETER(hWndDlg);
  118. return(TRUE);
  119. }
  120. BOOL OCPage::OnInitDialog(
  121. HWND hWndDlg,
  122. WPARAM wParam,
  123. LPARAM lParam
  124. )
  125. {
  126. UNREFERENCED_PARAMETER(lParam);
  127. UNREFERENCED_PARAMETER(wParam);
  128. UNREFERENCED_PARAMETER(hWndDlg);
  129. return(TRUE);
  130. }
  131. BOOL OCPage::ApplyChanges(
  132. )
  133. {
  134. return(TRUE);
  135. }
  136. DWORD
  137. OCPage::DisplayMessageBox(
  138. UINT resText,
  139. UINT resTitle,
  140. UINT uType,
  141. int *mbRetVal
  142. )
  143. {
  144. return(::DisplayMessageBox(m_hDlgWnd, resText, resTitle, uType, mbRetVal));
  145. }
  146. DWORD
  147. DisplayMessageBox(
  148. HWND hWnd,
  149. UINT resText,
  150. UINT resTitle,
  151. UINT uType,
  152. int *mbRetVal
  153. )
  154. {
  155. int iRet;
  156. TCHAR szResText[1024];
  157. TCHAR szResTitle[1024];
  158. if (mbRetVal == NULL) {
  159. return(ERROR_INVALID_PARAMETER);
  160. }
  161. iRet = LoadString(
  162. GetInstance(),
  163. resText,
  164. szResText,
  165. 1024
  166. );
  167. if (iRet == 0) {
  168. return(GetLastError());
  169. }
  170. iRet = LoadString(
  171. GetInstance(),
  172. resTitle,
  173. szResTitle,
  174. 1024
  175. );
  176. if (iRet == 0) {
  177. return(GetLastError());
  178. }
  179. *mbRetVal = MessageBox(
  180. hWnd,
  181. szResText,
  182. szResTitle,
  183. uType
  184. );
  185. return(*mbRetVal == 0 ? ERROR_OUTOFMEMORY : ERROR_SUCCESS);
  186. }