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.

816 lines
22 KiB

  1. #include "acBrowser.h"
  2. #include "resource.h"
  3. #include <commctrl.h>
  4. #include <commdlg.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <stdarg.h>
  8. extern PDBENTRY g_pEntries;
  9. #define SHOW_W_SHIMS 0x00000001
  10. #define SHOW_W_FLAGS 0x00000002
  11. #define SHOW_W_LAYERS 0x00000004
  12. #define SHOW_W_PATCHES 0x00000008
  13. #define SHOW_W_APPHELP 0x00000010
  14. #define SHOW_WO_SHIMS 0x00000100
  15. #define SHOW_WO_FLAGS 0x00000200
  16. #define SHOW_WO_LAYERS 0x00000400
  17. #define SHOW_WO_PATCHES 0x00000800
  18. #define SHOW_WO_APPHELP 0x00001000
  19. //
  20. // These flags cannot occur simultaneously.
  21. //
  22. #define SHOW_MORETHAN5 0x00010000
  23. #define SHOW_NOMATCHING 0x00020000
  24. #define SHOW_DISABLED_ONLY 0x80000000
  25. #define ID_SHOW_CONTENT 1234
  26. //
  27. // Global Variables
  28. //
  29. HINSTANCE g_hInstance;
  30. HWND g_hDlg;
  31. HWND g_hwndList;
  32. HWND g_hwndEntryTree;
  33. int g_nItems;
  34. BOOL g_bSortAppAsc;
  35. BOOL g_bSortExeAsc;
  36. PDBENTRY g_pSelEntry;
  37. char g_szBinary[MAX_PATH];
  38. DWORD g_dwCrtShowFlags = 0xFFFFFFFF;
  39. #define COLUMN_APP 0
  40. #define COLUMN_EXE 1
  41. char* g_szSeverity[] = { "NONE",
  42. "NOBLOCK",
  43. "HARDBLOCK",
  44. "MINORPROBLEM",
  45. "REINSTALL",
  46. "VERSIONSUB",
  47. "SHIM"};
  48. #define IDQ_ALL 0
  49. #define IDQ_MORETHAN5 1
  50. #define IDQ_NOMATCHING 2
  51. char* g_aszQueries[] = { "All entries",
  52. "Entries with more than 5 extra matching files",
  53. "Entries with no extra matching files",
  54. ""
  55. };
  56. void
  57. LogMsg(
  58. LPSTR pszFmt,
  59. ... )
  60. {
  61. CHAR gszT[1024];
  62. va_list arglist;
  63. va_start(arglist, pszFmt);
  64. _vsnprintf(gszT, 1023, pszFmt, arglist);
  65. gszT[1023] = 0;
  66. va_end(arglist);
  67. OutputDebugString(gszT);
  68. }
  69. /*******************************************************************************
  70. * CenterWindow
  71. *
  72. * This function must be called at the WM_INIDIALOG in order to
  73. * move the dialog window centered in the client area of the
  74. * parent or owner window.
  75. *******************************************************************************/
  76. BOOL CenterWindow(
  77. HWND hWnd)
  78. {
  79. RECT rectWindow, rectParent, rectScreen;
  80. int nCX, nCY;
  81. HWND hParent;
  82. POINT ptPoint;
  83. hParent = GetParent(hWnd);
  84. if (hParent == NULL)
  85. hParent = GetDesktopWindow();
  86. GetWindowRect(hParent, (LPRECT)&rectParent);
  87. GetWindowRect(hWnd, (LPRECT)&rectWindow);
  88. GetWindowRect(GetDesktopWindow(), (LPRECT)&rectScreen);
  89. nCX = rectWindow.right - rectWindow.left;
  90. nCY = rectWindow.bottom - rectWindow.top;
  91. ptPoint.x = ((rectParent.right + rectParent.left) / 2) - (nCX / 2);
  92. ptPoint.y = ((rectParent.bottom + rectParent.top ) / 2) - (nCY / 2);
  93. if (ptPoint.x < rectScreen.left)
  94. ptPoint.x = rectScreen.left;
  95. if (ptPoint.x > rectScreen.right - nCX)
  96. ptPoint.x = rectScreen.right - nCX;
  97. if (ptPoint.y < rectScreen.top)
  98. ptPoint.y = rectScreen.top;
  99. if (ptPoint.y > rectScreen.bottom - nCY)
  100. ptPoint.y = rectScreen.bottom - nCY;
  101. if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)
  102. ScreenToClient(hParent, (LPPOINT)&ptPoint);
  103. if (!MoveWindow(hWnd, ptPoint.x, ptPoint.y, nCX, nCY, TRUE))
  104. return FALSE;
  105. return TRUE;
  106. }
  107. void
  108. AddEntryToList(
  109. PDBENTRY pEntry
  110. )
  111. {
  112. LVITEM lvi;
  113. lvi.mask = LVIF_TEXT | LVIF_PARAM;
  114. lvi.pszText = pEntry->pszAppName;
  115. lvi.iItem = g_nItems;
  116. lvi.iSubItem = COLUMN_APP;
  117. lvi.lParam = (LPARAM)pEntry;
  118. ListView_InsertItem(g_hwndList, &lvi);
  119. ListView_SetItemText(g_hwndList, g_nItems, COLUMN_EXE, pEntry->pszExeName);
  120. g_nItems++;
  121. }
  122. void
  123. InsertColumnIntoListView(
  124. LPSTR lpszColumn,
  125. DWORD dwSubItem,
  126. DWORD widthPercent
  127. )
  128. {
  129. LVCOLUMN lvc;
  130. RECT rcClient;
  131. DWORD width;
  132. GetWindowRect(g_hwndList, &rcClient);
  133. width = rcClient.right - rcClient.left -
  134. 4 * GetSystemMetrics(SM_CXBORDER) -
  135. GetSystemMetrics(SM_CXVSCROLL);
  136. width = width * widthPercent / 100;
  137. lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
  138. lvc.fmt = LVCFMT_LEFT;
  139. lvc.iSubItem = dwSubItem;
  140. lvc.cx = width;
  141. lvc.pszText = lpszColumn;
  142. ListView_InsertColumn(g_hwndList, dwSubItem, &lvc);
  143. }
  144. void
  145. UpdateEntryTreeView(
  146. PDBENTRY pEntry
  147. )
  148. {
  149. HTREEITEM hItemExe;
  150. HTREEITEM hMatchItem;
  151. HTREEITEM hItemMatchingFiles;
  152. PMATCHINGFILE pMatch;
  153. PFIXLIST pFixList;
  154. TV_INSERTSTRUCT is;
  155. char szText[256];
  156. TreeView_DeleteAllItems(g_hwndEntryTree);
  157. wsprintf(szText, "%s - %s", pEntry->pszExeName, pEntry->szGUID);
  158. is.hParent = TVI_ROOT;
  159. is.hInsertAfter = TVI_LAST;
  160. is.item.mask = TVIF_TEXT | TVIF_PARAM;
  161. is.item.lParam = 0;
  162. is.item.pszText = szText;
  163. hItemExe = TreeView_InsertItem(g_hwndEntryTree, &is);
  164. if (pEntry->appHelp.bPresent) {
  165. wsprintf(szText, "AppHelp - %s",
  166. g_szSeverity[pEntry->appHelp.severity]);
  167. is.hParent = hItemExe;
  168. is.item.pszText = szText;
  169. TreeView_InsertItem(g_hwndEntryTree, &is);
  170. }
  171. if (pEntry->pFirstShim) {
  172. HTREEITEM hItemShims;
  173. is.hParent = hItemExe;
  174. is.hInsertAfter = TVI_SORT;
  175. is.item.lParam = 0;
  176. is.item.pszText = "Compatibility Fixes";
  177. hItemShims = TreeView_InsertItem(g_hwndEntryTree, &is);
  178. is.hParent = hItemShims;
  179. pFixList = pEntry->pFirstShim;
  180. while (pFixList) {
  181. is.item.lParam = (LPARAM)pFixList->pFix->pszDescription;
  182. is.item.pszText = pFixList->pFix->pszName;
  183. TreeView_InsertItem(g_hwndEntryTree, &is);
  184. pFixList = pFixList->pNext;
  185. }
  186. TreeView_Expand(g_hwndEntryTree, hItemShims, TVE_EXPAND);
  187. }
  188. if (pEntry->pFirstPatch) {
  189. HTREEITEM hItemPatches;
  190. is.hParent = hItemExe;
  191. is.hInsertAfter = TVI_SORT;
  192. is.item.lParam = 0;
  193. is.item.pszText = "Compatibility Patches";
  194. hItemPatches = TreeView_InsertItem(g_hwndEntryTree, &is);
  195. is.hParent = hItemPatches;
  196. pFixList = pEntry->pFirstPatch;
  197. while (pFixList) {
  198. is.item.lParam = (LPARAM)pFixList->pFix->pszDescription;
  199. is.item.pszText = pFixList->pFix->pszName;
  200. TreeView_InsertItem(g_hwndEntryTree, &is);
  201. pFixList = pFixList->pNext;
  202. }
  203. TreeView_Expand(g_hwndEntryTree, hItemPatches, TVE_EXPAND);
  204. }
  205. if (pEntry->pFirstFlag) {
  206. HTREEITEM hItemFlags;
  207. is.hParent = hItemExe;
  208. is.hInsertAfter = TVI_SORT;
  209. is.item.lParam = 0;
  210. is.item.pszText = "Compatibility Flags";
  211. hItemFlags = TreeView_InsertItem(g_hwndEntryTree, &is);
  212. is.hParent = hItemFlags;
  213. pFixList = pEntry->pFirstFlag;
  214. while (pFixList) {
  215. is.item.lParam = (LPARAM)pFixList->pFix->pszDescription;
  216. is.item.pszText = pFixList->pFix->pszName;
  217. TreeView_InsertItem(g_hwndEntryTree, &is);
  218. pFixList = pFixList->pNext;
  219. }
  220. TreeView_Expand(g_hwndEntryTree, hItemFlags, TVE_EXPAND);
  221. }
  222. if (pEntry->pFirstLayer) {
  223. HTREEITEM hItemLayers;
  224. is.hParent = hItemExe;
  225. is.hInsertAfter = TVI_SORT;
  226. is.item.lParam = 0;
  227. is.item.pszText = "Compatibility Layers";
  228. hItemLayers = TreeView_InsertItem(g_hwndEntryTree, &is);
  229. is.hParent = hItemLayers;
  230. pFixList = pEntry->pFirstLayer;
  231. while (pFixList) {
  232. is.item.lParam = (LPARAM)pFixList->pFix->pszDescription;
  233. is.item.pszText = pFixList->pFix->pszName;
  234. TreeView_InsertItem(g_hwndEntryTree, &is);
  235. pFixList = pFixList->pNext;
  236. }
  237. TreeView_Expand(g_hwndEntryTree, hItemLayers, TVE_EXPAND);
  238. }
  239. pMatch = pEntry->pFirstMatchingFile;
  240. is.hParent = hItemExe;
  241. is.item.lParam = 0;
  242. is.item.pszText = "Matching Files";
  243. hItemMatchingFiles = TreeView_InsertItem(g_hwndEntryTree, &is);
  244. while (pMatch) {
  245. PATTRIBUTE pAttr;
  246. is.hInsertAfter = TVI_SORT;
  247. is.hParent = hItemMatchingFiles;
  248. is.item.pszText = pMatch->pszName;
  249. hMatchItem = TreeView_InsertItem(g_hwndEntryTree, &is);
  250. pAttr = pMatch->pFirstAttribute;
  251. while (pAttr) {
  252. is.hParent = hMatchItem;
  253. is.hInsertAfter = TVI_SORT;
  254. is.item.pszText = pAttr->pszText;
  255. TreeView_InsertItem(g_hwndEntryTree, &is);
  256. pAttr = pAttr->pNext;
  257. }
  258. pMatch = pMatch->pNext;
  259. }
  260. TreeView_Expand(g_hwndEntryTree, hItemMatchingFiles, TVE_EXPAND);
  261. TreeView_Expand(g_hwndEntryTree, hItemExe, TVE_EXPAND);
  262. }
  263. void
  264. AppSelectedChanged(
  265. HWND hdlg,
  266. int nSel
  267. )
  268. {
  269. LVITEM lvi;
  270. PDBENTRY pEntry;
  271. if (nSel == -1)
  272. return;
  273. lvi.iItem = nSel;
  274. lvi.iSubItem = 0;
  275. lvi.mask = LVIF_PARAM;
  276. ListView_GetItem(g_hwndList, &lvi);
  277. pEntry = (PDBENTRY)lvi.lParam;
  278. g_pSelEntry = pEntry;
  279. //
  280. // Update the entry tree view
  281. //
  282. UpdateEntryTreeView(pEntry);
  283. SendDlgItemMessage(hdlg, IDC_PER_USER, BM_SETCHECK,
  284. (pEntry->bDisablePerUser ? BST_CHECKED : BST_UNCHECKED), 0);
  285. SendDlgItemMessage(hdlg, IDC_PER_MACHINE, BM_SETCHECK,
  286. (pEntry->bDisablePerMachine ? BST_CHECKED : BST_UNCHECKED), 0);
  287. }
  288. int CALLBACK
  289. CompareItems(
  290. LPARAM lParam1,
  291. LPARAM lParam2,
  292. LPARAM column)
  293. {
  294. PDBENTRY pItem1 = (PDBENTRY)lParam1;
  295. PDBENTRY pItem2 = (PDBENTRY)lParam2;
  296. int nVal = 0;
  297. if (column == COLUMN_APP) {
  298. if (g_bSortAppAsc) {
  299. nVal = lstrcmpi(pItem1->pszAppName, pItem2->pszAppName);
  300. } else {
  301. nVal = lstrcmpi(pItem2->pszAppName, pItem1->pszAppName);
  302. }
  303. }
  304. if (column == COLUMN_EXE) {
  305. if (g_bSortExeAsc) {
  306. nVal = lstrcmpi(pItem1->pszExeName, pItem2->pszExeName);
  307. } else {
  308. nVal = lstrcmpi(pItem2->pszExeName, pItem1->pszExeName);
  309. }
  310. }
  311. return nVal;
  312. }
  313. void
  314. ShowFixes(
  315. HWND hdlg,
  316. DWORD dwShowFlags
  317. )
  318. {
  319. PDBENTRY pEntry;
  320. char szEntries[128];
  321. BOOL bDontShow;
  322. if (dwShowFlags == g_dwCrtShowFlags) {
  323. return;
  324. }
  325. g_nItems = 0;
  326. SendMessage(g_hwndList, WM_SETREDRAW, FALSE, 0);
  327. ListView_DeleteAllItems(g_hwndList);
  328. pEntry = g_pEntries;
  329. while (pEntry != NULL) {
  330. bDontShow = (pEntry->pFirstShim == NULL && (dwShowFlags & SHOW_W_SHIMS) ||
  331. pEntry->appHelp.bPresent == FALSE && (dwShowFlags & SHOW_W_APPHELP) ||
  332. pEntry->pFirstFlag == NULL && (dwShowFlags & SHOW_W_FLAGS) ||
  333. pEntry->pFirstPatch == NULL && (dwShowFlags & SHOW_W_PATCHES) ||
  334. pEntry->pFirstLayer == NULL && (dwShowFlags & SHOW_W_LAYERS));
  335. bDontShow = bDontShow ||
  336. (pEntry->pFirstShim && (dwShowFlags & SHOW_WO_SHIMS) ||
  337. pEntry->appHelp.bPresent && (dwShowFlags & SHOW_WO_APPHELP) ||
  338. pEntry->pFirstFlag && (dwShowFlags & SHOW_WO_FLAGS) ||
  339. pEntry->pFirstPatch && (dwShowFlags & SHOW_WO_PATCHES) ||
  340. pEntry->pFirstLayer && (dwShowFlags & SHOW_WO_LAYERS));
  341. if ((dwShowFlags & SHOW_DISABLED_ONLY) &&
  342. !pEntry->bDisablePerMachine &&
  343. !pEntry->bDisablePerUser) {
  344. bDontShow = TRUE;
  345. }
  346. if (dwShowFlags & SHOW_MORETHAN5) {
  347. if (pEntry->nMatchingFiles < 6) {
  348. bDontShow = TRUE;
  349. }
  350. }
  351. if (dwShowFlags & SHOW_NOMATCHING) {
  352. if (pEntry->nMatchingFiles > 1) {
  353. bDontShow = TRUE;
  354. }
  355. }
  356. if (!bDontShow) {
  357. AddEntryToList(pEntry);
  358. }
  359. pEntry = pEntry->pNext;
  360. }
  361. ListView_SortItems(g_hwndList, CompareItems, COLUMN_APP);
  362. wsprintf(szEntries, "%d entries. Use the headers to sort them.", g_nItems);
  363. SetDlgItemText(hdlg, IDC_ALL_ENTRIES, szEntries);
  364. SendMessage(g_hwndList, WM_SETREDRAW, TRUE, 0);
  365. g_dwCrtShowFlags = dwShowFlags;
  366. }
  367. void
  368. DoInitDialog(
  369. HWND hdlg
  370. )
  371. {
  372. HICON hIcon;
  373. int i;
  374. g_hDlg = hdlg;
  375. CenterWindow(hdlg);
  376. g_hwndList = GetDlgItem(hdlg, IDC_LIST);
  377. ListView_SetExtendedListViewStyle(g_hwndList, 0x20);
  378. g_hwndEntryTree = GetDlgItem(hdlg, IDC_ENTRY);
  379. g_nItems = 0;
  380. InsertColumnIntoListView("Application", COLUMN_APP, 60);
  381. InsertColumnIntoListView("Main Binary", COLUMN_EXE, 40);
  382. g_bSortAppAsc = TRUE;
  383. g_bSortExeAsc = FALSE;
  384. //
  385. // Show the app icon.
  386. //
  387. hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_APPICON));
  388. SetClassLongPtr(hdlg, GCLP_HICON, (LONG_PTR)hIcon);
  389. SendDlgItemMessage(hdlg, IDC_DC_APPHELP, BM_SETCHECK, BST_CHECKED, 0);
  390. SendDlgItemMessage(hdlg, IDC_DC_SHIMS, BM_SETCHECK, BST_CHECKED, 0);
  391. SendDlgItemMessage(hdlg, IDC_DC_FLAGS, BM_SETCHECK, BST_CHECKED, 0);
  392. SendDlgItemMessage(hdlg, IDC_DC_PATCHES, BM_SETCHECK, BST_CHECKED, 0);
  393. SendDlgItemMessage(hdlg, IDC_DC_LAYERS, BM_SETCHECK, BST_CHECKED, 0);
  394. //
  395. // Populate the statistics queries
  396. //
  397. for (i = 0; *g_aszQueries[i] != 0; i++) {
  398. SendDlgItemMessage(hdlg, IDC_STATISTICS, CB_ADDSTRING, 0, (LPARAM)g_aszQueries[i]);
  399. }
  400. SetCursor(NULL);
  401. SetTimer(hdlg, ID_SHOW_CONTENT, 100, NULL);
  402. }
  403. void
  404. FilterAndShow(
  405. HWND hdlg
  406. )
  407. {
  408. DWORD dwShowFlags = 0;
  409. if (SendDlgItemMessage(hdlg, IDC_W_APPHELP, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  410. dwShowFlags |= SHOW_W_APPHELP;
  411. } else if (SendDlgItemMessage(hdlg, IDC_WO_APPHELP, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  412. dwShowFlags |= SHOW_WO_APPHELP;
  413. }
  414. if (SendDlgItemMessage(hdlg, IDC_W_SHIMS, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  415. dwShowFlags |= SHOW_W_SHIMS;
  416. } else if (SendDlgItemMessage(hdlg, IDC_WO_SHIMS, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  417. dwShowFlags |= SHOW_WO_SHIMS;
  418. }
  419. if (SendDlgItemMessage(hdlg, IDC_W_PATCHES, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  420. dwShowFlags |= SHOW_W_PATCHES;
  421. } else if (SendDlgItemMessage(hdlg, IDC_WO_PATCHES, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  422. dwShowFlags |= SHOW_WO_PATCHES;
  423. }
  424. if (SendDlgItemMessage(hdlg, IDC_W_FLAGS, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  425. dwShowFlags |= SHOW_W_FLAGS;
  426. } else if (SendDlgItemMessage(hdlg, IDC_WO_FLAGS, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  427. dwShowFlags |= SHOW_WO_FLAGS;
  428. }
  429. if (SendDlgItemMessage(hdlg, IDC_W_LAYERS, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  430. dwShowFlags |= SHOW_W_LAYERS;
  431. } else if (SendDlgItemMessage(hdlg, IDC_WO_LAYERS, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  432. dwShowFlags |= SHOW_WO_LAYERS;
  433. }
  434. if (SendDlgItemMessage(hdlg, IDC_DISABLED_ONLY, BM_GETCHECK, 0, 0) == BST_CHECKED) {
  435. dwShowFlags |= SHOW_DISABLED_ONLY;
  436. }
  437. SendDlgItemMessage(hdlg, IDC_PER_USER, BM_SETCHECK, BST_UNCHECKED, 0);
  438. SendDlgItemMessage(hdlg, IDC_PER_MACHINE, BM_SETCHECK, BST_UNCHECKED, 0);
  439. ShowFixes(hdlg, dwShowFlags);
  440. TreeView_DeleteAllItems(g_hwndEntryTree);
  441. }
  442. void
  443. OnSubmitChanges(
  444. HWND hdlg
  445. )
  446. {
  447. BOOL bPerUser, bPerMachine;
  448. if (g_pSelEntry == NULL) {
  449. return;
  450. }
  451. bPerUser = (SendDlgItemMessage(hdlg, IDC_PER_USER, BM_GETCHECK, 0, 0) == BST_CHECKED);
  452. bPerMachine = (SendDlgItemMessage(hdlg, IDC_PER_MACHINE, BM_GETCHECK, 0, 0) == BST_CHECKED);
  453. UpdateFixStatus(g_pSelEntry->szGUID, bPerUser, bPerMachine);
  454. g_pSelEntry->bDisablePerUser = bPerUser;
  455. g_pSelEntry->bDisablePerMachine = bPerMachine;
  456. }
  457. INT_PTR CALLBACK
  458. BrowseAppCompatDlgProc(
  459. HWND hdlg,
  460. UINT uMsg,
  461. WPARAM wParam,
  462. LPARAM lParam
  463. )
  464. {
  465. int wCode = LOWORD(wParam);
  466. int wNotifyCode = HIWORD(wParam);
  467. switch (uMsg) {
  468. case WM_INITDIALOG:
  469. DoInitDialog(hdlg);
  470. break;
  471. case WM_TIMER:
  472. if (wParam == ID_SHOW_CONTENT) {
  473. KillTimer(hdlg, ID_SHOW_CONTENT);
  474. //
  475. // Read the database
  476. //
  477. GetDatabaseEntries();
  478. ShowFixes(hdlg, 0);
  479. SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
  480. }
  481. break;
  482. case WM_NOTIFY:
  483. if (wParam == IDC_LIST) {
  484. LPNMHDR pnm = (LPNMHDR)lParam;
  485. switch (pnm->code) {
  486. case LVN_COLUMNCLICK:
  487. {
  488. LPNMLISTVIEW pnmlv = (LPNMLISTVIEW)lParam;
  489. if (pnmlv->iSubItem == COLUMN_APP) {
  490. g_bSortAppAsc = !g_bSortAppAsc;
  491. }
  492. if (pnmlv->iSubItem == COLUMN_EXE) {
  493. g_bSortExeAsc = !g_bSortExeAsc;
  494. }
  495. ListView_SortItems(g_hwndList, CompareItems, pnmlv->iSubItem);
  496. break;
  497. }
  498. case LVN_ITEMCHANGED:
  499. {
  500. int nSel = ListView_GetSelectionMark(g_hwndList);
  501. AppSelectedChanged(hdlg, nSel);
  502. break;
  503. }
  504. case NM_CLICK:
  505. {
  506. LVHITTESTINFO ht;
  507. int nSel;
  508. GetCursorPos(&ht.pt);
  509. ScreenToClient(g_hwndList, &ht.pt);
  510. nSel = ListView_SubItemHitTest(g_hwndList, &ht);
  511. if (nSel != -1) {
  512. ListView_SetItemState(g_hwndList,
  513. nSel,
  514. LVIS_SELECTED | LVIS_FOCUSED,
  515. LVIS_SELECTED | LVIS_FOCUSED);
  516. }
  517. AppSelectedChanged(hdlg, nSel);
  518. break;
  519. }
  520. default:
  521. break;
  522. }
  523. } else if (wParam == IDC_ENTRY) {
  524. LPNMHDR pnm = (LPNMHDR)lParam;
  525. switch (pnm->code) {
  526. case TVN_GETINFOTIP:
  527. {
  528. LPNMTVGETINFOTIP lpGetInfoTip = (LPNMTVGETINFOTIP)lParam;
  529. if (lpGetInfoTip->lParam != 0) {
  530. lstrcpy(lpGetInfoTip->pszText, (char*)lpGetInfoTip->lParam);
  531. }
  532. break;
  533. }
  534. }
  535. }
  536. break;
  537. case WM_COMMAND:
  538. if (wNotifyCode == CBN_SELCHANGE) {
  539. int nSel;
  540. nSel = (int)SendDlgItemMessage(hdlg, IDC_STATISTICS, CB_GETCURSEL, 0, 0);
  541. switch (nSel) {
  542. case IDQ_ALL:
  543. ShowFixes(hdlg, (g_dwCrtShowFlags & ~(SHOW_MORETHAN5 | SHOW_NOMATCHING)));
  544. break;
  545. case IDQ_MORETHAN5:
  546. ShowFixes(hdlg, ((g_dwCrtShowFlags | SHOW_MORETHAN5) & ~SHOW_NOMATCHING));
  547. break;
  548. case IDQ_NOMATCHING:
  549. ShowFixes(hdlg, ((g_dwCrtShowFlags | SHOW_NOMATCHING) & ~SHOW_MORETHAN5));
  550. break;
  551. }
  552. }
  553. switch (wCode) {
  554. case IDC_PER_USER:
  555. case IDC_PER_MACHINE:
  556. OnSubmitChanges(hdlg);
  557. break;
  558. case IDC_W_APPHELP:
  559. case IDC_W_SHIMS:
  560. case IDC_W_FLAGS:
  561. case IDC_W_LAYERS:
  562. case IDC_W_PATCHES:
  563. case IDC_WO_APPHELP:
  564. case IDC_WO_SHIMS:
  565. case IDC_WO_FLAGS:
  566. case IDC_WO_LAYERS:
  567. case IDC_WO_PATCHES:
  568. case IDC_DC_APPHELP:
  569. case IDC_DC_SHIMS:
  570. case IDC_DC_FLAGS:
  571. case IDC_DC_LAYERS:
  572. case IDC_DC_PATCHES:
  573. case IDC_DISABLED_ONLY:
  574. FilterAndShow(hdlg);
  575. break;
  576. case IDCANCEL:
  577. EndDialog(hdlg, TRUE);
  578. break;
  579. default:
  580. return FALSE;
  581. }
  582. break;
  583. default:
  584. return FALSE;
  585. }
  586. return TRUE;
  587. }
  588. int APIENTRY WinMain(HINSTANCE hInstance,
  589. HINSTANCE hPrevInstance,
  590. LPSTR lpCmdLine,
  591. int nCmdShow)
  592. {
  593. InitCommonControls();
  594. g_hInstance = hInstance;
  595. DialogBox(hInstance,
  596. MAKEINTRESOURCE(IDD_DIALOG),
  597. GetDesktopWindow(),
  598. BrowseAppCompatDlgProc);
  599. return 0;
  600. }