[SNDVOL32] Add the small line dialog
[reactos.git] / base / applications / taskmgr / proclist.c
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 Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "precomp.h"
24
25 INT_PTR CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
26
27 WNDPROC OldProcessListWndProc;
28
29
30 INT_PTR CALLBACK
31 ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
32 {
33 HBRUSH hbrBackground;
34 RECT rcItem;
35 RECT rcClip;
36 HDC hDC;
37 int DcSave;
38
39 switch (message)
40 {
41 case WM_ERASEBKGND:
42
43 /*
44 * The list control produces a nasty flicker
45 * when the user is resizing the window because
46 * it erases the background to white, then
47 * paints the list items over it.
48 *
49 * We will clip the drawing so that it only
50 * erases the parts of the list control that
51 * show only the background.
52 */
53
54 /*
55 * Get the device context and save it's state
56 * to be restored after we're done
57 */
58 hDC = (HDC) wParam;
59 DcSave = SaveDC(hDC);
60
61 /*
62 * Get the background brush
63 */
64 hbrBackground = (HBRUSH)(LONG_PTR) GetClassLongPtrW(hWnd, GCL_HBRBACKGROUND);
65
66 /*
67 * Calculate the clip rect by getting the RECT
68 * of the first and last items and adding them up.
69 *
70 * We also have to get the item's icon RECT and
71 * subtract it from our clip rect because we don't
72 * use icons in this list control.
73 */
74 rcClip.left = LVIR_BOUNDS;
75 SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM)&rcClip);
76 rcItem.left = LVIR_BOUNDS;
77 SendMessageW(hWnd, LVM_GETITEMRECT, ListView_GetItemCount(hWnd) - 1, (LPARAM)&rcItem);
78 rcClip.bottom = rcItem.bottom;
79 rcClip.right = rcItem.right;
80 rcItem.left = LVIR_ICON;
81 SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM)&rcItem);
82 rcClip.left = rcItem.right;
83
84 /*
85 * Now exclude the clip rect
86 */
87 ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom);
88
89 /*
90 * Now erase the background
91 *
92 *
93 * FIXME: Should I erase it myself or
94 * pass down the updated HDC and let
95 * the default handler do it?
96 */
97 GetClientRect(hWnd, &rcItem);
98 FillRect(hDC, &rcItem, hbrBackground);
99
100 /*
101 * Now restore the DC state that we
102 * saved earlier
103 */
104 RestoreDC(hDC, DcSave);
105
106 return TRUE;
107 }
108
109 /*
110 * We pass on all messages except WM_ERASEBKGND
111 */
112 return CallWindowProcW(OldProcessListWndProc, hWnd, message, wParam, lParam);
113 }