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.

69 lines
2.1 KiB

  1. /*
  2. * lvchk - common dialog proc handler for check-listview pages
  3. */
  4. #include "tweakui.h"
  5. #pragma BEGIN_CONST_DATA
  6. #pragma END_CONST_DATA
  7. /*****************************************************************************
  8. *
  9. * Checklist_OnInitDialog
  10. *
  11. * Walk the items that can live on the checklist.
  12. *
  13. * If the item can't report its state, then don't put it on the list.
  14. *
  15. *****************************************************************************/
  16. void PASCAL
  17. Checklist_OnInitDialog(HWND hwnd, PCCHECKLISTITEM rgcli, int ccli,
  18. UINT ids, LPVOID pvRef)
  19. {
  20. TCHAR tsz[MAX_PATH];
  21. int dids;
  22. for (dids = 0; dids < ccli; dids++) {
  23. BOOL f = rgcli[dids].GetCheckValue(rgcli[dids].lParam, pvRef);
  24. if (f >= 0) {
  25. LoadString(hinstCur, ids+dids, tsz, cA(tsz));
  26. LV_AddItem(hwnd, dids, tsz, -1, f);
  27. }
  28. }
  29. }
  30. /*****************************************************************************
  31. *
  32. * Checklist_OnApply
  33. *
  34. * Walk the items in the checklist and dork them if they have changed.
  35. *
  36. * The fForce flag forces us to call the callback even if nothing changed.
  37. *
  38. *****************************************************************************/
  39. void PASCAL
  40. Checklist_OnApply(HWND hdlg, PCCHECKLISTITEM rgcli, LPVOID pvRef, BOOL fForce)
  41. {
  42. HWND hwnd = GetDlgItem(hdlg, IDC_ICONLV);
  43. int cItems = ListView_GetItemCount(hwnd);
  44. LV_ITEM lvi;
  45. for (lvi.iItem = 0; lvi.iItem < cItems; lvi.iItem++) {
  46. BOOL fNew, fOld;
  47. lvi.stateMask = LVIS_STATEIMAGEMASK;
  48. Misc_LV_GetItemInfo(hwnd, &lvi, lvi.iItem, LVIF_PARAM | LVIF_STATE);
  49. fNew = LV_IsChecked(&lvi);
  50. fOld = rgcli[lvi.lParam].GetCheckValue(rgcli[lvi.lParam].lParam,
  51. pvRef);
  52. if (fOld >= 0 && (fForce || fNew != fOld)) {
  53. if (!rgcli[lvi.lParam].SetCheckValue(fNew, rgcli[lvi.lParam].lParam,
  54. pvRef)) {
  55. lvi.state = INDEXTOSTATEIMAGEMASK(fOld + 1);
  56. ListView_SetItem(hwnd, &lvi); /* Restore the state */
  57. }
  58. }
  59. }
  60. }