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.

235 lines
4.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: tfcprop.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include <pch.cpp>
  11. #pragma hdrstop
  12. #include "tfcprop.h"
  13. extern HINSTANCE g_hInstance;
  14. PropertyPage::PropertyPage(UINT uIDD)
  15. {
  16. m_hWnd = NULL;
  17. ZeroMemory(&m_psp, sizeof(PROPSHEETPAGE));
  18. m_psp.dwSize = sizeof(PROPSHEETPAGE);
  19. m_psp.dwFlags = PSP_DEFAULT;
  20. m_psp.hInstance = g_hInstance;
  21. m_psp.pszTemplate = MAKEINTRESOURCE(uIDD);
  22. m_psp.pfnDlgProc = dlgProcPropPage;
  23. m_psp.lParam = (LPARAM)this;
  24. }
  25. PropertyPage::~PropertyPage()
  26. {
  27. }
  28. BOOL PropertyPage::OnCommand(WPARAM, LPARAM)
  29. {
  30. return TRUE;
  31. }
  32. BOOL PropertyPage::OnNotify(UINT idCtrl, NMHDR* pnmh)
  33. {
  34. return FALSE;
  35. }
  36. BOOL PropertyPage::UpdateData(BOOL fSuckFromDlg /*= TRUE*/)
  37. {
  38. return TRUE;
  39. }
  40. BOOL PropertyPage::OnSetActive()
  41. {
  42. return TRUE;
  43. }
  44. BOOL PropertyPage::OnKillActive()
  45. {
  46. return TRUE;
  47. }
  48. BOOL PropertyPage::OnInitDialog()
  49. {
  50. UpdateData(FALSE); // push to dlg
  51. return TRUE;
  52. }
  53. void PropertyPage::OnDestroy()
  54. {
  55. return;
  56. }
  57. BOOL PropertyPage::OnApply()
  58. {
  59. SetModified(FALSE);
  60. return TRUE;
  61. }
  62. void PropertyPage::OnCancel()
  63. {
  64. return;
  65. }
  66. void PropertyPage::OnOK()
  67. {
  68. return;
  69. }
  70. BOOL PropertyPage::OnWizardFinish()
  71. {
  72. return TRUE;
  73. }
  74. LRESULT PropertyPage::OnWizardNext()
  75. {
  76. return 0;
  77. }
  78. LRESULT PropertyPage::OnWizardBack()
  79. {
  80. return 0;
  81. }
  82. void PropertyPage::OnHelp(LPHELPINFO lpHelp)
  83. {
  84. return;
  85. }
  86. void PropertyPage::OnContextHelp(HWND hwnd)
  87. {
  88. return;
  89. }
  90. INT_PTR CALLBACK
  91. dlgProcPropPage(
  92. HWND hwndDlg,
  93. UINT uMsg,
  94. WPARAM wParam,
  95. LPARAM lParam )
  96. {
  97. HRESULT hr;
  98. PropertyPage* pPage = NULL;
  99. switch(uMsg)
  100. {
  101. case WM_INITDIALOG:
  102. {
  103. // save off PropertyPage*
  104. ASSERT(lParam);
  105. pPage = (PropertyPage*) ((PROPSHEETPAGE*)lParam)->lParam;
  106. ASSERT(pPage);
  107. SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LPARAM)pPage);
  108. // pass notification through
  109. pPage->m_hWnd = hwndDlg; // save our hwnd
  110. return pPage->OnInitDialog(); // call virtual fxn
  111. }
  112. case WM_DESTROY:
  113. {
  114. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  115. if (pPage == NULL)
  116. break;
  117. pPage->OnDestroy();
  118. break;
  119. }
  120. case WM_NOTIFY:
  121. {
  122. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  123. if (pPage == NULL)
  124. break;
  125. LRESULT lr;
  126. // catch special commands, drop other notifications
  127. switch( ((LPNMHDR)lParam) -> code)
  128. {
  129. case PSN_SETACTIVE:
  130. lr = (pPage->OnSetActive() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  131. break;
  132. case PSN_KILLACTIVE:
  133. lr = (pPage->OnKillActive() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  134. break;
  135. case PSN_APPLY:
  136. pPage->UpdateData(TRUE); // take from dlg
  137. lr = (pPage->OnApply() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  138. break;
  139. case PSN_WIZFINISH:
  140. pPage->UpdateData(TRUE); // take from dlg
  141. lr = (pPage->OnWizardFinish() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  142. break;
  143. case PSN_WIZBACK:
  144. pPage->UpdateData(TRUE); // take from dlg
  145. lr = pPage->OnWizardBack();
  146. break;
  147. case PSN_WIZNEXT:
  148. {
  149. pPage->UpdateData(TRUE); // take from dlg
  150. lr = pPage->OnWizardNext();
  151. break;
  152. }
  153. default:
  154. return pPage->OnNotify((int)wParam, (NMHDR*)lParam);
  155. }
  156. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, lr);
  157. return TRUE;
  158. }
  159. case WM_COMMAND:
  160. {
  161. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  162. if (pPage == NULL)
  163. break;
  164. // catch special commands, pass others through
  165. switch(LOWORD(wParam))
  166. {
  167. case IDOK:
  168. pPage->OnOK();
  169. // EndDialog(hwndDlg, 0);
  170. return 0;
  171. case IDCANCEL:
  172. pPage->OnCancel();
  173. // EndDialog(hwndDlg, 1);
  174. return 0;
  175. default:
  176. return pPage->OnCommand(wParam, lParam);
  177. }
  178. }
  179. case WM_HELP:
  180. {
  181. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  182. if (pPage == NULL)
  183. break;
  184. pPage->OnHelp((LPHELPINFO) lParam);
  185. break;
  186. }
  187. case WM_CONTEXTMENU:
  188. {
  189. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  190. if (pPage == NULL)
  191. break;
  192. pPage->OnContextHelp((HWND)wParam);
  193. break;
  194. }
  195. default:
  196. break;
  197. }
  198. return 0;
  199. }