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.

258 lines
5.3 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
  33. PropertyPage::OnNotify(
  34. UINT, // idCtrl
  35. NMHDR * /* pnmh */ )
  36. {
  37. return FALSE;
  38. }
  39. BOOL
  40. PropertyPage::UpdateData(
  41. BOOL /* fSuckFromDlg = TRUE */ )
  42. {
  43. return TRUE;
  44. }
  45. BOOL PropertyPage::OnSetActive()
  46. {
  47. return TRUE;
  48. }
  49. BOOL PropertyPage::OnKillActive()
  50. {
  51. return TRUE;
  52. }
  53. BOOL PropertyPage::OnInitDialog()
  54. {
  55. UpdateData(FALSE); // push to dlg
  56. return TRUE;
  57. }
  58. void PropertyPage::OnDestroy()
  59. {
  60. return;
  61. }
  62. BOOL PropertyPage::OnApply()
  63. {
  64. SetModified(FALSE);
  65. return TRUE;
  66. }
  67. void PropertyPage::OnCancel()
  68. {
  69. return;
  70. }
  71. void PropertyPage::OnOK()
  72. {
  73. return;
  74. }
  75. BOOL PropertyPage::OnWizardFinish()
  76. {
  77. return TRUE;
  78. }
  79. LRESULT PropertyPage::OnWizardNext()
  80. {
  81. return 0;
  82. }
  83. LRESULT PropertyPage::OnWizardBack()
  84. {
  85. return 0;
  86. }
  87. void
  88. PropertyPage::OnHelp(
  89. LPHELPINFO /* lpHelp */ )
  90. {
  91. return;
  92. }
  93. void
  94. PropertyPage::OnContextHelp(
  95. HWND /* hwnd */ )
  96. {
  97. return;
  98. }
  99. INT_PTR CALLBACK
  100. dlgProcPropPage(
  101. HWND hwndDlg,
  102. UINT uMsg,
  103. WPARAM wParam,
  104. LPARAM lParam)
  105. {
  106. PropertyPage* pPage = NULL;
  107. switch(uMsg)
  108. {
  109. case WM_INITDIALOG:
  110. {
  111. // save off PropertyPage*
  112. ASSERT(lParam);
  113. pPage = (PropertyPage*) ((PROPSHEETPAGE*)lParam)->lParam;
  114. ASSERT(pPage);
  115. SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LPARAM)pPage);
  116. // pass notification through
  117. pPage->m_hWnd = hwndDlg; // save our hwnd
  118. return pPage->OnInitDialog(); // call virtual fxn
  119. }
  120. case WM_DESTROY:
  121. {
  122. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  123. if (pPage == NULL)
  124. break;
  125. pPage->OnDestroy();
  126. break;
  127. }
  128. case WM_NOTIFY:
  129. {
  130. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  131. if (pPage == NULL)
  132. break;
  133. LRESULT lr;
  134. // catch special commands, drop other notifications
  135. switch( ((LPNMHDR)lParam) -> code)
  136. {
  137. case PSN_SETACTIVE:
  138. lr = (pPage->OnSetActive() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  139. break;
  140. case PSN_KILLACTIVE:
  141. lr = (pPage->OnKillActive() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  142. break;
  143. case PSN_APPLY:
  144. pPage->UpdateData(TRUE); // take from dlg
  145. lr = (pPage->OnApply() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  146. break;
  147. case PSN_WIZFINISH:
  148. pPage->UpdateData(TRUE); // take from dlg
  149. lr = (pPage->OnWizardFinish() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE); // bool
  150. break;
  151. case PSN_WIZBACK:
  152. pPage->UpdateData(TRUE); // take from dlg
  153. lr = pPage->OnWizardBack();
  154. break;
  155. case PSN_WIZNEXT:
  156. {
  157. pPage->UpdateData(TRUE); // take from dlg
  158. lr = pPage->OnWizardNext();
  159. break;
  160. }
  161. default:
  162. return pPage->OnNotify((int)wParam, (NMHDR*)lParam);
  163. }
  164. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, lr);
  165. return TRUE;
  166. }
  167. case WM_COMMAND:
  168. {
  169. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  170. if (pPage == NULL)
  171. break;
  172. // catch special commands, pass others through
  173. switch(LOWORD(wParam))
  174. {
  175. case IDOK:
  176. pPage->OnOK();
  177. // EndDialog(hwndDlg, 0);
  178. return 0;
  179. case IDCANCEL:
  180. pPage->OnCancel();
  181. // EndDialog(hwndDlg, 1);
  182. return 0;
  183. default:
  184. return pPage->OnCommand(wParam, lParam);
  185. }
  186. }
  187. case WM_HELP:
  188. {
  189. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  190. if (pPage == NULL)
  191. break;
  192. pPage->OnHelp((LPHELPINFO) lParam);
  193. break;
  194. }
  195. case WM_CONTEXTMENU:
  196. {
  197. pPage = (PropertyPage*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  198. if (pPage == NULL)
  199. break;
  200. pPage->OnContextHelp((HWND)wParam);
  201. break;
  202. }
  203. default:
  204. break;
  205. }
  206. return 0;
  207. }
  208. BOOL
  209. EnumHideChildProc(
  210. HWND hwnd,
  211. LPARAM /* lParam */ )
  212. {
  213. ShowWindow(hwnd, SW_HIDE);
  214. EnableWindow(hwnd, FALSE);
  215. return TRUE;
  216. }
  217. void PropertyPage::HideControls()
  218. {
  219. EnumChildWindows(m_hWnd, EnumHideChildProc, NULL);
  220. }