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.

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