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