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.

87 lines
1.9 KiB

  1. #include "shellprv.h"
  2. #pragma hdrstop
  3. // convert screen coords to listview view coordinates
  4. // convert listview client window coords into listview view coordinates
  5. void LVUtil_ClientToLV(HWND hwndLV, LPPOINT ppt)
  6. {
  7. POINT ptOrigin;
  8. if (!ListView_GetOrigin(hwndLV, &ptOrigin))
  9. return;
  10. ppt->x += ptOrigin.x;
  11. ppt->y += ptOrigin.y;
  12. }
  13. void LVUtil_ScreenToLV(HWND hwndLV, LPPOINT ppt)
  14. {
  15. ScreenToClient(hwndLV, ppt);
  16. LVUtil_ClientToLV(hwndLV, ppt);
  17. }
  18. // convert listview client window coords into listview view coordinates
  19. void LVUtil_LVToClient(HWND hwndLV, LPPOINT ppt)
  20. {
  21. POINT ptOrigin;
  22. if (!ListView_GetOrigin(hwndLV, &ptOrigin))
  23. return;
  24. ppt->x -= ptOrigin.x;
  25. ppt->y -= ptOrigin.y;
  26. }
  27. //
  28. // Parameters:
  29. // hwndLV -- Specifies the listview window
  30. // nItem -- Specifies the item to be altered
  31. // uState -- Specifies the new state of the item
  32. // uMask -- Specifies the state mask
  33. //
  34. void LVUtil_DragSetItemState(HWND hwndLV, int nItem, UINT uState, UINT uMask)
  35. {
  36. // check the state to see if it is already as we want to avoid
  37. // flashing while dragging
  38. if (ListView_GetItemState(hwndLV, nItem, uMask) != (uState & uMask))
  39. {
  40. DAD_ShowDragImage(FALSE);
  41. ListView_SetItemState(hwndLV, nItem, uState, uMask);
  42. UpdateWindow(hwndLV); // REVIEW, needed?
  43. DAD_ShowDragImage(TRUE);
  44. }
  45. }
  46. void LVUtil_DragSelectItem(HWND hwndLV, int nItem)
  47. {
  48. int nTemp;
  49. for (nTemp = ListView_GetItemCount(hwndLV) - 1; nTemp >= 0; --nTemp)
  50. {
  51. LVUtil_DragSetItemState(hwndLV, nTemp, nTemp == nItem ? LVIS_DROPHILITED : 0, LVIS_DROPHILITED);
  52. }
  53. }
  54. //
  55. // Note that it returns NULL, if iItem is -1.
  56. //
  57. LPARAM LVUtil_GetLParam(HWND hwndLV, int i)
  58. {
  59. LV_ITEM item;
  60. item.mask = LVIF_PARAM;
  61. item.iItem = i;
  62. item.iSubItem = 0;
  63. item.lParam = 0;
  64. if (i != -1)
  65. {
  66. ListView_GetItem(hwndLV, &item);
  67. }
  68. return item.lParam;
  69. }