Translation update.
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 LRESULT CALLBACK    ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
38
39 LONG                OldProcessListWndProc;
40
41
42 LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
43 {
44     HBRUSH    hbrBackground;
45     RECT    rcItem;
46     RECT    rcClip;
47     HDC        hDC;
48     int        DcSave;
49
50     switch (message)
51     {
52     case WM_ERASEBKGND:
53
54         /*
55          * The list control produces a nasty flicker
56          * when the user is resizing the window because
57          * it erases the background to white, then
58          * paints the list items over it.
59          *
60          * We will clip the drawing so that it only
61          * erases the parts of the list control that
62          * show only the background.
63          */
64
65         /*
66          * Get the device context and save it's state
67          * to be restored after we're done
68          */
69         hDC = (HDC) wParam;
70         DcSave = SaveDC(hDC);
71
72         /*
73          * Get the background brush
74          */
75         hbrBackground = (HBRUSH) GetClassLong(hWnd, GCL_HBRBACKGROUND);
76
77         /*
78          * Calculate the clip rect by getting the RECT
79          * of the first and last items and adding them up.
80          *
81          * We also have to get the item's icon RECT and
82          * subtract it from our clip rect because we don't
83          * use icons in this list control.
84          */
85         ListView_GetItemRect(hWnd, 0, &rcClip, LVIR_BOUNDS);
86         ListView_GetItemRect(hWnd, ListView_GetItemCount(hWnd) - 1, &rcItem, LVIR_BOUNDS);
87         rcClip.bottom = rcItem.bottom;
88         ListView_GetItemRect(hWnd, 0, &rcItem, LVIR_ICON);
89         rcClip.left = rcItem.right;
90
91         /*
92          * Now exclude the clip rect
93          */
94         ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom);
95
96         /*
97          * Now erase the background
98          *
99          *
100          * FIXME: Should I erase it myself or
101          * pass down the updated HDC and let
102          * the default handler do it?
103          */
104         GetClientRect(hWnd, &rcItem);
105         FillRect(hDC, &rcItem, hbrBackground);
106
107         /*
108          * Now restore the DC state that we
109          * saved earlier
110          */
111         RestoreDC(hDC, DcSave);
112         
113         return TRUE;
114     }
115
116     /*
117      * We pass on all messages except WM_ERASEBKGND
118      */
119     return CallWindowProc((WNDPROC)OldProcessListWndProc, hWnd, message, wParam, lParam);
120 }