1 /* 2 * PROJECT: ReactOS Task Manager 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 * PURPOSE: Processes List. 5 * COPYRIGHT: Copyright 1999-2001 Brian Palmer <brianp@reactos.org> 6 */ 7 8 #include "precomp.h" 9 10 INT_PTR CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 11 12 WNDPROC OldProcessListWndProc; 13 14 15 INT_PTR CALLBACK 16 ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 17 { 18 HBRUSH hbrBackground; 19 RECT rcItem; 20 RECT rcClip; 21 HDC hDC; 22 int DcSave; 23 24 switch (message) 25 { 26 case WM_ERASEBKGND: 27 28 /* 29 * The list control produces a nasty flicker 30 * when the user is resizing the window because 31 * it erases the background to white, then 32 * paints the list items over it. 33 * 34 * We will clip the drawing so that it only 35 * erases the parts of the list control that 36 * show only the background. 37 */ 38 39 /* 40 * Get the device context and save it's state 41 * to be restored after we're done 42 */ 43 hDC = (HDC) wParam; 44 DcSave = SaveDC(hDC); 45 46 /* 47 * Get the background brush 48 */ 49 hbrBackground = (HBRUSH)(LONG_PTR) GetClassLongPtrW(hWnd, GCL_HBRBACKGROUND); 50 51 /* 52 * Calculate the clip rect by getting the RECT 53 * of the first and last items and adding them up. 54 * 55 * We also have to get the item's icon RECT and 56 * subtract it from our clip rect because we don't 57 * use icons in this list control. 58 */ 59 rcClip.left = LVIR_BOUNDS; 60 SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM)&rcClip); 61 rcItem.left = LVIR_BOUNDS; 62 SendMessageW(hWnd, LVM_GETITEMRECT, ListView_GetItemCount(hWnd) - 1, (LPARAM)&rcItem); 63 rcClip.bottom = rcItem.bottom; 64 rcClip.right = rcItem.right; 65 rcItem.left = LVIR_ICON; 66 SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM)&rcItem); 67 rcClip.left = rcItem.right; 68 69 /* 70 * Now exclude the clip rect 71 */ 72 ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom); 73 74 /* 75 * Now erase the background 76 * 77 * 78 * FIXME: Should I erase it myself or 79 * pass down the updated HDC and let 80 * the default handler do it? 81 */ 82 GetClientRect(hWnd, &rcItem); 83 FillRect(hDC, &rcItem, hbrBackground); 84 85 /* 86 * Now restore the DC state that we 87 * saved earlier 88 */ 89 RestoreDC(hDC, DcSave); 90 91 return TRUE; 92 } 93 94 /* 95 * We pass on all messages except WM_ERASEBKGND 96 */ 97 return CallWindowProcW(OldProcessListWndProc, hWnd, message, wParam, lParam); 98 } 99