proclist.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * ReactOS Task Manager
  3. *
  4. * proclist.c
  5. *
  6. * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  21. */
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <windows.h>
  25. #include <commctrl.h>
  26. #include <winnt.h>
  27. #include "taskmgr.h"
  28. #include "perfdata.h"
  29. WNDPROC OldProcessListWndProc;
  30. LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  31. {
  32. HBRUSH hbrBackground;
  33. int count;
  34. RECT rcItem;
  35. RECT rcClip;
  36. HDC hDC;
  37. int DcSave;
  38. switch (message)
  39. {
  40. case WM_ERASEBKGND:
  41. /*
  42. * The list control produces a nasty flicker
  43. * when the user is resizing the window because
  44. * it erases the background to white, then
  45. * paints the list items over it.
  46. *
  47. * We will clip the drawing so that it only
  48. * erases the parts of the list control that
  49. * show only the background.
  50. */
  51. /*
  52. * Get the device context and save its state
  53. * to be restored after we're done
  54. */
  55. hDC = (HDC) wParam;
  56. DcSave = SaveDC(hDC);
  57. /*
  58. * Get the background brush
  59. */
  60. hbrBackground = (HBRUSH) GetClassLongPtrW(hWnd, GCLP_HBRBACKGROUND);
  61. /*
  62. * Calculate the clip rect by getting the RECT
  63. * of the first and last items and adding them up.
  64. *
  65. * We also have to get the item's icon RECT and
  66. * subtract it from our clip rect because we don't
  67. * use icons in this list control.
  68. */
  69. rcClip.left = LVIR_BOUNDS;
  70. SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM) &rcClip);
  71. rcItem.left = LVIR_BOUNDS;
  72. count = SendMessageW(hWnd, LVM_GETITEMCOUNT, 0, 0);
  73. SendMessageW(hWnd, LVM_GETITEMRECT, count - 1, (LPARAM) &rcItem);
  74. rcClip.bottom = rcItem.bottom;
  75. rcItem.left = LVIR_ICON;
  76. SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM) &rcItem);
  77. rcClip.left = rcItem.right;
  78. /*
  79. * Now exclude the clip rect
  80. */
  81. ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom);
  82. /*
  83. * Now erase the background
  84. *
  85. *
  86. * FIXME: Should I erase it myself or
  87. * pass down the updated HDC and let
  88. * the default handler do it?
  89. */
  90. GetClientRect(hWnd, &rcItem);
  91. FillRect(hDC, &rcItem, hbrBackground);
  92. /*
  93. * Now restore the DC state that we
  94. * saved earlier
  95. */
  96. RestoreDC(hDC, DcSave);
  97. return TRUE;
  98. }
  99. /*
  100. * We pass on all messages except WM_ERASEBKGND
  101. */
  102. return CallWindowProcW(OldProcessListWndProc, hWnd, message, wParam, lParam);
  103. }