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.

228 lines
5.0 KiB

  1. // AVOptions.cpp : Implementation of CAppVerifierOptions
  2. #include "precomp.h"
  3. #include "avoptions.h"
  4. #include <commctrl.h>
  5. #include <cassert>
  6. extern BOOL g_bBreakOnLog;
  7. extern BOOL g_bFullPageHeap;
  8. extern BOOL g_bPropagateTests;
  9. extern wstring g_wstrExeName;
  10. BOOL
  11. CALLBACK
  12. CAppVerifierOptions::DlgViewOptions(
  13. HWND hDlg,
  14. UINT message,
  15. WPARAM wParam,
  16. LPARAM lParam
  17. )
  18. {
  19. switch (message) {
  20. case WM_INITDIALOG:
  21. return TRUE;
  22. case WM_NOTIFY:
  23. switch (((NMHDR FAR *) lParam)->code) {
  24. case PSN_APPLY:
  25. ::SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
  26. break;
  27. case PSN_QUERYCANCEL:
  28. return FALSE;
  29. }
  30. }
  31. return FALSE;
  32. }
  33. void
  34. CAppVerifierOptions::CreatePropertySheet(
  35. HWND hWndParent
  36. )
  37. {
  38. CTestInfo* pTest;
  39. DWORD dwPages = 1;
  40. DWORD dwPage = 0;
  41. LPCWSTR szExe = g_wstrExeName.c_str();
  42. //
  43. // count the number of pages
  44. //
  45. for (pTest = g_aTestInfo.begin(); pTest != g_aTestInfo.end(); pTest++) {
  46. if (pTest->PropSheetPage.pfnDlgProc) {
  47. dwPages++;
  48. }
  49. }
  50. m_phPages = new HPROPSHEETPAGE[dwPages];
  51. if (!m_phPages) {
  52. return;
  53. }
  54. //
  55. // init the global page
  56. //
  57. m_PageGlobal.dwSize = sizeof(PROPSHEETPAGE);
  58. m_PageGlobal.dwFlags = PSP_USETITLE;
  59. m_PageGlobal.hInstance = g_hInstance;
  60. m_PageGlobal.pszTemplate = MAKEINTRESOURCE(IDD_AV_OPTIONS);
  61. m_PageGlobal.pfnDlgProc = DlgViewOptions;
  62. m_PageGlobal.pszTitle = MAKEINTRESOURCE(IDS_GLOBAL_OPTIONS);
  63. m_PageGlobal.lParam = 0;
  64. m_PageGlobal.pfnCallback = NULL;
  65. m_phPages[0] = CreatePropertySheetPage(&m_PageGlobal);
  66. if (!m_phPages[0]) {
  67. //
  68. // we need the global page minimum
  69. //
  70. return;
  71. }
  72. //
  73. // add the pages for the various tests
  74. //
  75. dwPage = 1;
  76. for (pTest = g_aTestInfo.begin(); pTest != g_aTestInfo.end(); pTest++) {
  77. if (pTest->PropSheetPage.pfnDlgProc) {
  78. //
  79. // we use the lParam to identify the exe involved
  80. //
  81. pTest->PropSheetPage.lParam = (LPARAM)szExe;
  82. m_phPages[dwPage] = CreatePropertySheetPage(&(pTest->PropSheetPage));
  83. if (!m_phPages[dwPage]) {
  84. dwPages--;
  85. } else {
  86. dwPage++;
  87. }
  88. }
  89. }
  90. //wstring wstrOptions;
  91. //AVLoadString(IDS_OPTIONS_TITLE, wstrOptions);
  92. //wstrOptions += L" - ";
  93. //wstrOptions += szExe;
  94. m_psh.dwSize = sizeof(PROPSHEETHEADER);
  95. m_psh.dwFlags = PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP;
  96. m_psh.hwndParent = hWndParent;
  97. m_psh.hInstance = g_hInstance;
  98. m_psh.pszCaption = L"Options";
  99. m_psh.nPages = dwPages;
  100. m_psh.nStartPage = 0;
  101. m_psh.phpage = m_phPages;
  102. m_psh.pfnCallback = NULL;
  103. }
  104. HWND
  105. CAppVerifierOptions::CreateControlWindow(
  106. HWND hwndParent,
  107. RECT& rcPos
  108. )
  109. {
  110. //HWND hwnd =
  111. //CComCompositeControl<CAppVerifierOptions>::CreateControlWindow(hwndParent, rcPos);
  112. //
  113. // Now would be a good time to check all the global options.
  114. //
  115. /*if (g_bBreakOnLog) {
  116. SendMessage(GetDlgItem(IDC_BREAK_ON_LOG), BM_SETCHECK, BST_CHECKED, 0);
  117. }
  118. if (g_bFullPageHeap) {
  119. SendMessage(GetDlgItem(IDC_FULL_PAGEHEAP), BM_SETCHECK, BST_CHECKED, 0);
  120. }
  121. if (g_bPropagateTests) {
  122. SendMessage(GetDlgItem(IDC_PROPAGATE_TESTS_TO_CHILDREN), BM_SETCHECK, BST_CHECKED, 0);
  123. }*/
  124. //m_hWndOptionsDlg = hwnd;
  125. m_hWndParent = hwndParent;
  126. return NULL;
  127. }
  128. LRESULT
  129. CAppVerifierOptions::OnInitDialog(
  130. UINT uMsg,
  131. WPARAM wParam,
  132. LPARAM lParam,
  133. BOOL& bHandled
  134. )
  135. {
  136. CreatePropertySheet(m_hWndParent);
  137. bHandled = TRUE;
  138. return 0;
  139. }
  140. LRESULT
  141. CAppVerifierOptions::OnClose(
  142. UINT uMsg,
  143. WPARAM wParam,
  144. LPARAM lParam,
  145. BOOL& bHandled
  146. )
  147. {
  148. bHandled = FALSE;
  149. return 0;
  150. }
  151. //
  152. // We receive this when the dialog is being displayed.
  153. //
  154. LRESULT
  155. CAppVerifierOptions::OnSetFocus(
  156. UINT uMsg,
  157. WPARAM wParam,
  158. LPARAM lParam,
  159. BOOL& bHandled
  160. )
  161. {
  162. PropertySheet(&m_psh);
  163. bHandled = TRUE;
  164. return 0;
  165. }
  166. LRESULT
  167. CAppVerifierOptions::OnItemChecked(
  168. WORD wNotifyCode,
  169. WORD wID,
  170. HWND hWndCtl,
  171. BOOL& bHandled
  172. )
  173. {
  174. bHandled = TRUE;
  175. BOOL bCheck = (SendMessage(hWndCtl, BM_GETCHECK, 0, 0) == BST_CHECKED) ? TRUE : FALSE;
  176. switch (wID) {
  177. case IDC_BREAK_ON_LOG:
  178. g_bBreakOnLog = bCheck;
  179. break;
  180. case IDC_FULL_PAGEHEAP:
  181. g_bFullPageHeap = bCheck;
  182. break;
  183. case IDC_PROPAGATE_TESTS_TO_CHILDREN:
  184. g_bPropagateTests = bCheck;
  185. break;
  186. default:
  187. bHandled = FALSE;
  188. break;
  189. }
  190. return 0;
  191. }