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.

126 lines
2.5 KiB

  1. #define TestWF(hwnf, f) (GetWindowLong(hwnd, GWL_STYLE) & (f))
  2. BOOL DVAIsClipped(HDC hdc, RECT& rc)
  3. {
  4. RECT rcClip;
  5. if (GetClipBox(hdc, &rcClip) != SIMPLEREGION)
  6. return TRUE;
  7. if (rc.left < rcClip.left ||
  8. rc.top < rcClip.top ||
  9. rc.right > rcClip.right ||
  10. rc.bottom > rcClip.bottom)
  11. return TRUE;
  12. return FALSE;
  13. }
  14. int DVAGetClipList(HWND hwnd, LPRECT prc, LPRECT RectList, int RectCount)
  15. {
  16. RECT rc;
  17. HWND hwndP;
  18. HWND hwndT;
  19. if (RectCount == 0 || !IsVisible(hwnd))
  20. return 0;
  21. //
  22. // get the client area of the window
  23. //
  24. GetClientRect(hwnd, RectList);
  25. if (prcTest)
  26. IntersectRect(RectList, RectList, prc);
  27. ClientToScreen(hwnd, (LPPOINT)RectList);
  28. ClientToScreen(hwnd, (LPPOINT)RectList + 1);
  29. RectCount = 1;
  30. RectList[1] = RectList[0];
  31. //
  32. // walk all children of hwnd and remove them if needed
  33. //
  34. if (TestWF(hwnd WS_CLIPCHILDREN))
  35. {
  36. RectCount = ExcludeWindowRects(RectList, RectCount,
  37. GetWindow(hwnd, GW_CHILD), NULL);
  38. if (RectCount == 0)
  39. return 0;
  40. }
  41. //
  42. // walk all the siblings of hwnd and exclude them from the list.
  43. //
  44. for (; (hwndP = GetWindow(hwnd, GW_PARENT)) != NULL; hwnd = hwndP)
  45. {
  46. GetWindowRect(hwndP, &rc);
  47. RectCount = IntersectRectList(RectList, RectCount, &rc;
  48. if (RectCount == 0)
  49. return 0;
  50. if (TestWF(hwnd, WS_CLIPSIBLINGS))
  51. {
  52. RectCount = ExcludeWindowRects(RectList, RectCount,
  53. GetWindow(hwndP, GW_CHILD), hwnd);
  54. if (RectCount == 0)
  55. return 0;
  56. }
  57. }
  58. return RectCount;
  59. }
  60. int ExcludeWindowRects(LPRECT RectList, int RectCount, HWND hwndA, HWND hwndB)
  61. {
  62. RECT rc;
  63. for (hwnd = hwndA; hwnd != NULL && hwnd != hwndB; hwnd = GetWindow(hwnd, GW_HWNDNEXT))
  64. {
  65. if (!IsWindowVisible(hwnd))
  66. continue;
  67. // Don't subtract off transparent windows...
  68. //
  69. if (TestWF(hwnd, WEFTRANSPARENT))
  70. continue;
  71. GetWindowRect(hwnd, &rc);
  72. RectCount = ExcludeRectList(RectList, RectCount, &rc);
  73. if (RectCount == 0)
  74. return 0;
  75. }
  76. return RectCount;
  77. }
  78. int ExcludeRectList(LPRECT RectList, int RectCount, LPRECT prc)
  79. {
  80. int i;
  81. int n;
  82. RECT rc;
  83. if (RectCount == 0)
  84. return 0;
  85. SubtractRect(RectList, prc);
  86. for (i=1; i <= RectCount; i++)
  87. {
  88. if (!IntersectRect(&rc, &RectList[i], prc))
  89. continue;
  90. //
  91. //
  92. //
  93. }
  94. }