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.

265 lines
8.4 KiB

  1. //
  2. // Advanced.C
  3. //
  4. #include "sigverif.h"
  5. //
  6. // Initialization of search dialog.
  7. //
  8. BOOL Search_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  9. {
  10. TCHAR szBuffer[MAX_PATH];
  11. UNREFERENCED_PARAMETER(hwndFocus);
  12. UNREFERENCED_PARAMETER(lParam);
  13. g_App.hSearch = hwnd;
  14. //
  15. // Since the "check system files" option is faster, check that option by
  16. // default.
  17. //
  18. if (!g_App.bUserScan) {
  19. CheckRadioButton(hwnd, IDC_SCAN, IDC_NOTMS, IDC_SCAN);
  20. } else {
  21. CheckRadioButton(hwnd, IDC_SCAN, IDC_NOTMS, IDC_NOTMS);
  22. }
  23. //
  24. // Pre-load the user's search path with the Windows directory
  25. //
  26. if (!*g_App.szScanPath) {
  27. MyGetWindowsDirectory(g_App.szScanPath, cA(g_App.szScanPath));
  28. }
  29. //
  30. // Display the current search folder
  31. //
  32. SetDlgItemText(hwnd, IDC_FOLDER, g_App.szScanPath);
  33. //
  34. // Pre-load the user's search pattern with "*.*"
  35. //
  36. if (!*g_App.szScanPattern) {
  37. MyLoadString(g_App.szScanPattern, cA(g_App.szScanPattern), IDS_ALL);
  38. }
  39. //
  40. // Display the current search pattern.
  41. //
  42. SetDlgItemText(hwnd, IDC_TYPE, szBuffer);
  43. //
  44. // Now disable all the dialog items associated with IDS_NOTMS
  45. //
  46. if (!g_App.bUserScan) {
  47. EnableWindow(GetDlgItem(hwnd, IDC_SUBFOLDERS), FALSE);
  48. EnableWindow(GetDlgItem(hwnd, IDC_TYPE), FALSE);
  49. EnableWindow(GetDlgItem(hwnd, IDC_FOLDER), FALSE);
  50. EnableWindow(GetDlgItem(hwnd, ID_BROWSE), FALSE);
  51. }
  52. //
  53. // If we are searching subdirectories, check the SubFolders checkbox
  54. //
  55. if (g_App.bSubFolders) {
  56. CheckDlgButton(hwnd, IDC_SUBFOLDERS, BST_CHECKED);
  57. } else {
  58. CheckDlgButton(hwnd, IDC_SUBFOLDERS, BST_UNCHECKED);
  59. }
  60. //
  61. // Set the combobox value to g_App.szScanPattern
  62. //
  63. SetDlgItemText(hwnd, IDC_TYPE, g_App.szScanPattern);
  64. //
  65. // Initialize the combobox with several pre-defined extension types
  66. //
  67. MyLoadString(szBuffer, cA(szBuffer), IDS_EXE);
  68. SendMessage(GetDlgItem(hwnd, IDC_TYPE), CB_ADDSTRING, (WPARAM) 0, (LPARAM) szBuffer);
  69. MyLoadString(szBuffer, cA(szBuffer), IDS_DLL);
  70. SendMessage(GetDlgItem(hwnd, IDC_TYPE), CB_ADDSTRING, (WPARAM) 0, (LPARAM) szBuffer);
  71. MyLoadString(szBuffer, cA(szBuffer), IDS_SYS);
  72. SendMessage(GetDlgItem(hwnd, IDC_TYPE), CB_ADDSTRING, (WPARAM) 0, (LPARAM) szBuffer);
  73. MyLoadString(szBuffer, cA(szBuffer), IDS_DRV);
  74. SendMessage(GetDlgItem(hwnd, IDC_TYPE), CB_ADDSTRING, (WPARAM) 0, (LPARAM) szBuffer);
  75. MyLoadString(szBuffer, cA(szBuffer), IDS_OCX);
  76. SendMessage(GetDlgItem(hwnd, IDC_TYPE), CB_ADDSTRING, (WPARAM) 0, (LPARAM) szBuffer);
  77. MyLoadString(szBuffer, cA(szBuffer), IDS_ALL);
  78. SendMessage(GetDlgItem(hwnd, IDC_TYPE), CB_ADDSTRING, (WPARAM) 0, (LPARAM) szBuffer);
  79. return TRUE;
  80. }
  81. //
  82. // Handle any WM_COMMAND messages sent to the search dialog
  83. //
  84. void Search_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
  85. {
  86. UNREFERENCED_PARAMETER(hwndCtl);
  87. UNREFERENCED_PARAMETER(codeNotify);
  88. switch(id) {
  89. case ID_BROWSE:
  90. //
  91. // The user clicked the ID_BROWSE button, so call BrowseForFolder and
  92. // update IDC_FOLDER
  93. //
  94. if (BrowseForFolder(hwnd, g_App.szScanPath, cA(g_App.szScanPath))) {
  95. SetDlgItemText(hwnd, IDC_FOLDER, g_App.szScanPath);
  96. }
  97. break;
  98. case IDC_SCAN:
  99. //
  100. // The user clicked IDC_SCAN, so disable all the IDC_NOTMS controls
  101. //
  102. if (!g_App.bScanning) {
  103. EnableWindow(GetDlgItem(hwnd, IDC_SUBFOLDERS), FALSE);
  104. EnableWindow(GetDlgItem(hwnd, IDC_TYPE), FALSE);
  105. EnableWindow(GetDlgItem(hwnd, IDC_FOLDER), FALSE);
  106. EnableWindow(GetDlgItem(hwnd, ID_BROWSE), FALSE);
  107. }
  108. break;
  109. case IDC_NOTMS:
  110. //
  111. // The user clicked IDC_NOTMS, so make sure all the controls are enabled
  112. //
  113. if (!g_App.bScanning) {
  114. EnableWindow(GetDlgItem(hwnd, IDC_SUBFOLDERS), TRUE);
  115. EnableWindow(GetDlgItem(hwnd, IDC_TYPE), TRUE);
  116. EnableWindow(GetDlgItem(hwnd, IDC_FOLDER), TRUE);
  117. EnableWindow(GetDlgItem(hwnd, ID_BROWSE), TRUE);
  118. }
  119. break;
  120. }
  121. }
  122. //
  123. // This function handles any notification messages for the Search page.
  124. //
  125. LRESULT Search_NotifyHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  126. {
  127. NMHDR *lpnmhdr = (NMHDR *) lParam;
  128. UNREFERENCED_PARAMETER(uMsg);
  129. UNREFERENCED_PARAMETER(wParam);
  130. switch(lpnmhdr->code) {
  131. case PSN_APPLY:
  132. g_App.bUserScan = (IsDlgButtonChecked(hwnd, IDC_NOTMS) == BST_CHECKED);
  133. if (g_App.bUserScan) {
  134. if (GetWindowTextLength(GetDlgItem(hwnd, IDC_FOLDER)) > cA(g_App.szScanPath)) {
  135. //
  136. // The folder path that was entered is too long to fit into our
  137. // buffer, so tell the user the path is invalid and stay on
  138. // the property page.
  139. //
  140. MyErrorBoxId(IDS_INVALID_FOLDER);
  141. SetWindowLongPtr(hwnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  142. return TRUE;
  143. } else {
  144. //
  145. // Get the search pattern from the combobox and update g_App.szScanPattern
  146. //
  147. GetDlgItemText(hwnd, IDC_TYPE, g_App.szScanPattern, cA(g_App.szScanPattern));
  148. //
  149. // Get the path from the edit control and update g_App.szScanPath
  150. //
  151. GetDlgItemText(hwnd, IDC_FOLDER, g_App.szScanPath, cA(g_App.szScanPath));
  152. //
  153. // Get the checked/unchecked state of the "SubFolders" checkbox
  154. //
  155. g_App.bSubFolders = (IsDlgButtonChecked(hwnd, IDC_SUBFOLDERS) == BST_CHECKED);
  156. }
  157. }
  158. }
  159. return 0;
  160. }
  161. //
  162. // The search dialog procedure. Needs to handle WM_INITDIALOG, WM_COMMAND, and WM_CLOSE/WM_DESTROY.
  163. //
  164. INT_PTR CALLBACK Search_DlgProc(HWND hwnd, UINT uMsg,
  165. WPARAM wParam, LPARAM lParam)
  166. {
  167. BOOL fProcessed = TRUE;
  168. switch (uMsg) {
  169. HANDLE_MSG(hwnd, WM_INITDIALOG, Search_OnInitDialog);
  170. HANDLE_MSG(hwnd, WM_COMMAND, Search_OnCommand);
  171. case WM_NOTIFY:
  172. return Search_NotifyHandler(hwnd, uMsg, wParam, lParam);
  173. case WM_HELP:
  174. SigVerif_Help(hwnd, uMsg, wParam, lParam, FALSE);
  175. break;
  176. case WM_CONTEXTMENU:
  177. SigVerif_Help(hwnd, uMsg, wParam, lParam, TRUE);
  178. break;
  179. default: fProcessed = FALSE;
  180. }
  181. return fProcessed;
  182. }
  183. void AdvancedPropertySheet(HWND hwnd)
  184. {
  185. PROPSHEETPAGE psp[NUM_PAGES];
  186. PROPSHEETHEADER psh;
  187. TCHAR szCaption[MAX_PATH];
  188. TCHAR szPage1[MAX_PATH];
  189. TCHAR szPage2[MAX_PATH];
  190. ZeroMemory(&psp[0], sizeof(PROPSHEETPAGE));
  191. psp[0].dwSize = sizeof(PROPSHEETPAGE);
  192. psp[0].dwFlags = PSP_USEHICON | PSP_USETITLE;
  193. psp[0].hInstance = g_App.hInstance;
  194. psp[0].pszTemplate = MAKEINTRESOURCE(IDD_SEARCH);
  195. psp[0].hIcon = g_App.hIcon;
  196. psp[0].pfnDlgProc = Search_DlgProc;
  197. MyLoadString(szPage1, cA(szPage1), IDS_SEARCHTAB);
  198. psp[0].pszTitle = szPage1;
  199. psp[0].lParam = 0;
  200. psp[0].pfnCallback = NULL;
  201. ZeroMemory(&psp[1], sizeof(PROPSHEETPAGE));
  202. psp[1].dwSize = sizeof(PROPSHEETPAGE);
  203. psp[1].dwFlags = PSP_USEHICON | PSP_USETITLE;
  204. psp[1].hInstance = g_App.hInstance;
  205. psp[1].pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS);
  206. psp[1].hIcon = g_App.hIcon;
  207. psp[1].pfnDlgProc = LogFile_DlgProc;
  208. MyLoadString(szPage2, cA(szPage2), IDS_LOGGINGTAB);
  209. psp[1].pszTitle = szPage2;
  210. psp[1].lParam = 0;
  211. psp[1].pfnCallback = NULL;
  212. ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
  213. psh.dwSize = sizeof(PROPSHEETHEADER);
  214. psh.dwFlags = PSH_USEHICON | PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
  215. psh.hwndParent = hwnd;
  216. psh.hInstance = g_App.hInstance;
  217. psh.hIcon = g_App.hIcon;
  218. MyLoadString(szCaption, cA(szCaption), IDS_ADVANCED_SETTINGS);
  219. psh.pszCaption = szCaption;
  220. psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  221. psh.nStartPage = 0;
  222. psh.ppsp = (LPCPROPSHEETPAGE)psp;
  223. psh.pfnCallback = NULL;
  224. PropertySheet(&psh);
  225. }