Added support for VT_I8/VT_UI8 marshalling.
[wine] / programs / taskmgr / column.c
1 /*
2  *  ReactOS Task Manager
3  *
4  *  column.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     
32 #include "taskmgr.h"
33 #include "column.h"
34
35 UINT    ColumnDataHints[25];
36
37 int                 InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem);
38 INT_PTR CALLBACK    ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
39
40 void AddColumns(void)
41 {
42     int        size;
43
44     if (TaskManagerSettings.Column_ImageName)
45         InsertColumn(0, _T("Image Name"), LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[0], -1);
46     if (TaskManagerSettings.Column_PID)
47         InsertColumn(1, _T("PID"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[1], -1);
48     if (TaskManagerSettings.Column_UserName)
49         InsertColumn(2, _T("Username"), LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[2], -1);
50     if (TaskManagerSettings.Column_SessionID)
51         InsertColumn(3, _T("Session ID"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[3], -1);
52     if (TaskManagerSettings.Column_CPUUsage)
53         InsertColumn(4, _T("CPU"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[4], -1);
54     if (TaskManagerSettings.Column_CPUTime)
55         InsertColumn(5, _T("CPU Time"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[5], -1);
56     if (TaskManagerSettings.Column_MemoryUsage)
57         InsertColumn(6, _T("Mem Usage"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[6], -1);
58     if (TaskManagerSettings.Column_PeakMemoryUsage)
59         InsertColumn(7, _T("Peak Mem Usage"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[7], -1);
60     if (TaskManagerSettings.Column_MemoryUsageDelta)
61         InsertColumn(8, _T("Mem Delta"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[8], -1);
62     if (TaskManagerSettings.Column_PageFaults)
63         InsertColumn(9, _T("Page Faults"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[9], -1);
64     if (TaskManagerSettings.Column_PageFaultsDelta)
65         InsertColumn(10, _T("PF Delta"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[10], -1);
66     if (TaskManagerSettings.Column_VirtualMemorySize)
67         InsertColumn(11, _T("VM Size"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[11], -1);
68     if (TaskManagerSettings.Column_PagedPool)
69         InsertColumn(12, _T("Paged Pool"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[12], -1);
70     if (TaskManagerSettings.Column_NonPagedPool)
71         InsertColumn(13, _T("NP Pool"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[13], -1);
72     if (TaskManagerSettings.Column_BasePriority)
73         InsertColumn(14, _T("Base Pri"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[14], -1);
74     if (TaskManagerSettings.Column_HandleCount)
75         InsertColumn(15, _T("Handles"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[15], -1);
76     if (TaskManagerSettings.Column_ThreadCount)
77         InsertColumn(16, _T("Threads"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[16], -1);
78     if (TaskManagerSettings.Column_USERObjects)
79         InsertColumn(17, _T("USER Objects"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[17], -1);
80     if (TaskManagerSettings.Column_GDIObjects)
81         InsertColumn(18, _T("GDI Objects"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[18], -1);
82     if (TaskManagerSettings.Column_IOReads)
83         InsertColumn(19, _T("I/O Reads"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[19], -1);
84     if (TaskManagerSettings.Column_IOWrites)
85         InsertColumn(20, _T("I/O Writes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[20], -1);
86     if (TaskManagerSettings.Column_IOOther)
87         InsertColumn(21, _T("I/O Other"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[21], -1);
88     if (TaskManagerSettings.Column_IOReadBytes)
89         InsertColumn(22, _T("I/O Read Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[22], -1);
90     if (TaskManagerSettings.Column_IOWriteBytes)
91         InsertColumn(23, _T("I/O Write Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[23], -1);
92     if (TaskManagerSettings.Column_IOOtherBytes)
93         InsertColumn(24, _T("I/O Other Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[24], -1);
94
95     size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
96     SendMessage(hProcessPageHeaderCtrl, HDM_SETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
97
98     UpdateColumnDataHints();
99 }
100
101 int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
102 {
103     LVCOLUMN    column;
104
105     column.mask = LVCF_TEXT|LVCF_FMT;
106     column.pszText = (LPTSTR)lpszColumnHeading;
107     column.fmt = nFormat;
108
109     if (nWidth != -1)
110     {
111         column.mask |= LVCF_WIDTH;
112         column.cx = nWidth;
113     }
114
115     if (nSubItem != -1)
116     {
117         column.mask |= LVCF_SUBITEM;
118         column.iSubItem = nSubItem;
119     }
120
121     return ListView_InsertColumn(hProcessPageListCtrl, nCol, &column);
122 }
123
124 void SaveColumnSettings(void)
125 {
126     HDITEM    hditem;
127     int        i;
128     TCHAR    text[260];
129     int        size;
130
131     /* Reset column data */
132     for (i=0; i<25; i++)
133         TaskManagerSettings.ColumnOrderArray[i] = i;
134
135     TaskManagerSettings.Column_ImageName = FALSE;
136     TaskManagerSettings.Column_PID = FALSE;
137     TaskManagerSettings.Column_CPUUsage = FALSE;
138     TaskManagerSettings.Column_CPUTime = FALSE;
139     TaskManagerSettings.Column_MemoryUsage = FALSE;
140     TaskManagerSettings.Column_MemoryUsageDelta = FALSE;
141     TaskManagerSettings.Column_PeakMemoryUsage = FALSE;
142     TaskManagerSettings.Column_PageFaults = FALSE;
143     TaskManagerSettings.Column_USERObjects = FALSE;
144     TaskManagerSettings.Column_IOReads = FALSE;
145     TaskManagerSettings.Column_IOReadBytes = FALSE;
146     TaskManagerSettings.Column_SessionID = FALSE;
147     TaskManagerSettings.Column_UserName = FALSE;
148     TaskManagerSettings.Column_PageFaultsDelta = FALSE;
149     TaskManagerSettings.Column_VirtualMemorySize = FALSE;
150     TaskManagerSettings.Column_PagedPool = FALSE;
151     TaskManagerSettings.Column_NonPagedPool = FALSE;
152     TaskManagerSettings.Column_BasePriority = FALSE;
153     TaskManagerSettings.Column_HandleCount = FALSE;
154     TaskManagerSettings.Column_ThreadCount = FALSE;
155     TaskManagerSettings.Column_GDIObjects = FALSE;
156     TaskManagerSettings.Column_IOWrites = FALSE;
157     TaskManagerSettings.Column_IOWriteBytes = FALSE;
158     TaskManagerSettings.Column_IOOther = FALSE;
159     TaskManagerSettings.Column_IOOtherBytes = FALSE;
160     TaskManagerSettings.ColumnSizeArray[0] = 105;
161     TaskManagerSettings.ColumnSizeArray[1] = 50;
162     TaskManagerSettings.ColumnSizeArray[2] = 107;
163     TaskManagerSettings.ColumnSizeArray[3] = 70;
164     TaskManagerSettings.ColumnSizeArray[4] = 35;
165     TaskManagerSettings.ColumnSizeArray[5] = 70;
166     TaskManagerSettings.ColumnSizeArray[6] = 70;
167     TaskManagerSettings.ColumnSizeArray[7] = 100;
168     TaskManagerSettings.ColumnSizeArray[8] = 70;
169     TaskManagerSettings.ColumnSizeArray[9] = 70;
170     TaskManagerSettings.ColumnSizeArray[10] = 70;
171     TaskManagerSettings.ColumnSizeArray[11] = 70;
172     TaskManagerSettings.ColumnSizeArray[12] = 70;
173     TaskManagerSettings.ColumnSizeArray[13] = 70;
174     TaskManagerSettings.ColumnSizeArray[14] = 60;
175     TaskManagerSettings.ColumnSizeArray[15] = 60;
176     TaskManagerSettings.ColumnSizeArray[16] = 60;
177     TaskManagerSettings.ColumnSizeArray[17] = 60;
178     TaskManagerSettings.ColumnSizeArray[18] = 60;
179     TaskManagerSettings.ColumnSizeArray[19] = 70;
180     TaskManagerSettings.ColumnSizeArray[20] = 70;
181     TaskManagerSettings.ColumnSizeArray[21] = 70;
182     TaskManagerSettings.ColumnSizeArray[22] = 70;
183     TaskManagerSettings.ColumnSizeArray[23] = 70;
184     TaskManagerSettings.ColumnSizeArray[24] = 70;
185
186     /* Get header order */
187     size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
188     SendMessage(hProcessPageHeaderCtrl, HDM_GETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
189
190     /* Get visible columns */
191     for (i=0; i<SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); i++) {
192         memset(&hditem, 0, sizeof(HDITEM));
193
194         hditem.mask = HDI_TEXT|HDI_WIDTH;
195         hditem.pszText = text;
196         hditem.cchTextMax = 260;
197
198         SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, i, (LPARAM) &hditem);
199
200         if (_tcsicmp(text, _T("Image Name")) == 0)
201         {
202             TaskManagerSettings.Column_ImageName = TRUE;
203             TaskManagerSettings.ColumnSizeArray[0] = hditem.cxy;
204         }
205         if (_tcsicmp(text, _T("PID")) == 0)
206         {
207             TaskManagerSettings.Column_PID = TRUE;
208             TaskManagerSettings.ColumnSizeArray[1] = hditem.cxy;
209         }
210         if (_tcsicmp(text, _T("Username")) == 0)
211         {
212             TaskManagerSettings.Column_UserName = TRUE;
213             TaskManagerSettings.ColumnSizeArray[2] = hditem.cxy;
214         }
215         if (_tcsicmp(text, _T("Session ID")) == 0)
216         {
217             TaskManagerSettings.Column_SessionID = TRUE;
218             TaskManagerSettings.ColumnSizeArray[3] = hditem.cxy;
219         }
220         if (_tcsicmp(text, _T("CPU")) == 0)
221         {
222             TaskManagerSettings.Column_CPUUsage = TRUE;
223             TaskManagerSettings.ColumnSizeArray[4] = hditem.cxy;
224         }
225         if (_tcsicmp(text, _T("CPU Time")) == 0)
226         {
227             TaskManagerSettings.Column_CPUTime = TRUE;
228             TaskManagerSettings.ColumnSizeArray[5] = hditem.cxy;
229         }
230         if (_tcsicmp(text, _T("Mem Usage")) == 0)
231         {
232             TaskManagerSettings.Column_MemoryUsage = TRUE;
233             TaskManagerSettings.ColumnSizeArray[6] = hditem.cxy;
234         }
235         if (_tcsicmp(text, _T("Peak Mem Usage")) == 0)
236         {
237             TaskManagerSettings.Column_PeakMemoryUsage = TRUE;
238             TaskManagerSettings.ColumnSizeArray[7] = hditem.cxy;
239         }
240         if (_tcsicmp(text, _T("Mem Delta")) == 0)
241         {
242             TaskManagerSettings.Column_MemoryUsageDelta = TRUE;
243             TaskManagerSettings.ColumnSizeArray[8] = hditem.cxy;
244         }
245         if (_tcsicmp(text, _T("Page Faults")) == 0)
246         {
247             TaskManagerSettings.Column_PageFaults = TRUE;
248             TaskManagerSettings.ColumnSizeArray[9] = hditem.cxy;
249         }
250         if (_tcsicmp(text, _T("PF Delta")) == 0)
251         {
252             TaskManagerSettings.Column_PageFaultsDelta = TRUE;
253             TaskManagerSettings.ColumnSizeArray[10] = hditem.cxy;
254         }
255         if (_tcsicmp(text, _T("VM Size")) == 0)
256         {
257             TaskManagerSettings.Column_VirtualMemorySize = TRUE;
258             TaskManagerSettings.ColumnSizeArray[11] = hditem.cxy;
259         }
260         if (_tcsicmp(text, _T("Paged Pool")) == 0)
261         {
262             TaskManagerSettings.Column_PagedPool = TRUE;
263             TaskManagerSettings.ColumnSizeArray[12] = hditem.cxy;
264         }
265         if (_tcsicmp(text, _T("NP Pool")) == 0)
266         {
267             TaskManagerSettings.Column_NonPagedPool = TRUE;
268             TaskManagerSettings.ColumnSizeArray[13] = hditem.cxy;
269         }
270         if (_tcsicmp(text, _T("Base Pri")) == 0)
271         {
272             TaskManagerSettings.Column_BasePriority = TRUE;
273             TaskManagerSettings.ColumnSizeArray[14] = hditem.cxy;
274         }
275         if (_tcsicmp(text, _T("Handles")) == 0)
276         {
277             TaskManagerSettings.Column_HandleCount = TRUE;
278             TaskManagerSettings.ColumnSizeArray[15] = hditem.cxy;
279         }
280         if (_tcsicmp(text, _T("Threads")) == 0)
281         {
282             TaskManagerSettings.Column_ThreadCount = TRUE;
283             TaskManagerSettings.ColumnSizeArray[16] = hditem.cxy;
284         }
285         if (_tcsicmp(text, _T("USER Objects")) == 0)
286         {
287             TaskManagerSettings.Column_USERObjects = TRUE;
288             TaskManagerSettings.ColumnSizeArray[17] = hditem.cxy;
289         }
290         if (_tcsicmp(text, _T("GDI Objects")) == 0)
291         {
292             TaskManagerSettings.Column_GDIObjects = TRUE;
293             TaskManagerSettings.ColumnSizeArray[18] = hditem.cxy;
294         }
295         if (_tcsicmp(text, _T("I/O Reads")) == 0)
296         {
297             TaskManagerSettings.Column_IOReads = TRUE;
298             TaskManagerSettings.ColumnSizeArray[19] = hditem.cxy;
299         }
300         if (_tcsicmp(text, _T("I/O Writes")) == 0)
301         {
302             TaskManagerSettings.Column_IOWrites = TRUE;
303             TaskManagerSettings.ColumnSizeArray[20] = hditem.cxy;
304         }
305         if (_tcsicmp(text, _T("I/O Other")) == 0)
306         {
307             TaskManagerSettings.Column_IOOther = TRUE;
308             TaskManagerSettings.ColumnSizeArray[21] = hditem.cxy;
309         }
310         if (_tcsicmp(text, _T("I/O Read Bytes")) == 0)
311         {
312             TaskManagerSettings.Column_IOReadBytes = TRUE;
313             TaskManagerSettings.ColumnSizeArray[22] = hditem.cxy;
314         }
315         if (_tcsicmp(text, _T("I/O Write Bytes")) == 0)
316         {
317             TaskManagerSettings.Column_IOWriteBytes = TRUE;
318             TaskManagerSettings.ColumnSizeArray[23] = hditem.cxy;
319         }
320         if (_tcsicmp(text, _T("I/O Other Bytes")) == 0)
321         {
322             TaskManagerSettings.Column_IOOtherBytes = TRUE;
323             TaskManagerSettings.ColumnSizeArray[24] = hditem.cxy;
324         }
325     }
326 }
327
328 void ProcessPage_OnViewSelectColumns(void)
329 {
330     int        i;
331
332     if (DialogBox(hInst, MAKEINTRESOURCE(IDD_COLUMNS_DIALOG), hMainWnd, ColumnsDialogWndProc) == IDOK)
333     {
334         for (i=Header_GetItemCount(hProcessPageHeaderCtrl)-1; i>=0; i--)
335         {
336             ListView_DeleteColumn(hProcessPageListCtrl, i);
337         }
338
339         for (i=0; i<25; i++)
340             TaskManagerSettings.ColumnOrderArray[i] = i;
341
342         TaskManagerSettings.ColumnSizeArray[0] = 105;
343         TaskManagerSettings.ColumnSizeArray[1] = 50;
344         TaskManagerSettings.ColumnSizeArray[2] = 107;
345         TaskManagerSettings.ColumnSizeArray[3] = 70;
346         TaskManagerSettings.ColumnSizeArray[4] = 35;
347         TaskManagerSettings.ColumnSizeArray[5] = 70;
348         TaskManagerSettings.ColumnSizeArray[6] = 70;
349         TaskManagerSettings.ColumnSizeArray[7] = 100;
350         TaskManagerSettings.ColumnSizeArray[8] = 70;
351         TaskManagerSettings.ColumnSizeArray[9] = 70;
352         TaskManagerSettings.ColumnSizeArray[10] = 70;
353         TaskManagerSettings.ColumnSizeArray[11] = 70;
354         TaskManagerSettings.ColumnSizeArray[12] = 70;
355         TaskManagerSettings.ColumnSizeArray[13] = 70;
356         TaskManagerSettings.ColumnSizeArray[14] = 60;
357         TaskManagerSettings.ColumnSizeArray[15] = 60;
358         TaskManagerSettings.ColumnSizeArray[16] = 60;
359         TaskManagerSettings.ColumnSizeArray[17] = 60;
360         TaskManagerSettings.ColumnSizeArray[18] = 60;
361         TaskManagerSettings.ColumnSizeArray[19] = 70;
362         TaskManagerSettings.ColumnSizeArray[20] = 70;
363         TaskManagerSettings.ColumnSizeArray[21] = 70;
364         TaskManagerSettings.ColumnSizeArray[22] = 70;
365         TaskManagerSettings.ColumnSizeArray[23] = 70;
366         TaskManagerSettings.ColumnSizeArray[24] = 70;
367
368         AddColumns();
369     }
370 }
371
372 INT_PTR CALLBACK
373 ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
374 {
375
376     switch (message)
377     {
378     case WM_INITDIALOG:
379
380         if (TaskManagerSettings.Column_ImageName)
381             SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_SETCHECK, BST_CHECKED, 0);
382         if (TaskManagerSettings.Column_PID)
383             SendMessage(GetDlgItem(hDlg, IDC_PID), BM_SETCHECK, BST_CHECKED, 0);
384         if (TaskManagerSettings.Column_UserName)
385             SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_SETCHECK, BST_CHECKED, 0);
386         if (TaskManagerSettings.Column_SessionID)
387             SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_SETCHECK, BST_CHECKED, 0);
388         if (TaskManagerSettings.Column_CPUUsage)
389             SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_SETCHECK, BST_CHECKED, 0);
390         if (TaskManagerSettings.Column_CPUTime)
391             SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_SETCHECK, BST_CHECKED, 0);
392         if (TaskManagerSettings.Column_MemoryUsage)
393             SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
394         if (TaskManagerSettings.Column_PeakMemoryUsage)
395             SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
396         if (TaskManagerSettings.Column_MemoryUsageDelta)
397             SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_SETCHECK, BST_CHECKED, 0);
398         if (TaskManagerSettings.Column_PageFaults)
399             SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_SETCHECK, BST_CHECKED, 0);
400         if (TaskManagerSettings.Column_PageFaultsDelta)
401             SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_SETCHECK, BST_CHECKED, 0);
402         if (TaskManagerSettings.Column_VirtualMemorySize)
403             SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_SETCHECK, BST_CHECKED, 0);
404         if (TaskManagerSettings.Column_PagedPool)
405             SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
406         if (TaskManagerSettings.Column_NonPagedPool)
407             SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
408         if (TaskManagerSettings.Column_BasePriority)
409             SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_SETCHECK, BST_CHECKED, 0);
410         if (TaskManagerSettings.Column_HandleCount)
411             SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_SETCHECK, BST_CHECKED, 0);
412         if (TaskManagerSettings.Column_ThreadCount)
413             SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_SETCHECK, BST_CHECKED, 0);
414         if (TaskManagerSettings.Column_USERObjects)
415             SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_SETCHECK, BST_CHECKED, 0);
416         if (TaskManagerSettings.Column_GDIObjects)
417             SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_SETCHECK, BST_CHECKED, 0);
418         if (TaskManagerSettings.Column_IOReads)
419             SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_SETCHECK, BST_CHECKED, 0);
420         if (TaskManagerSettings.Column_IOWrites)
421             SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_SETCHECK, BST_CHECKED, 0);
422         if (TaskManagerSettings.Column_IOOther)
423             SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_SETCHECK, BST_CHECKED, 0);
424         if (TaskManagerSettings.Column_IOReadBytes)
425             SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_SETCHECK, BST_CHECKED, 0);
426         if (TaskManagerSettings.Column_IOWriteBytes)
427             SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_SETCHECK, BST_CHECKED, 0);
428         if (TaskManagerSettings.Column_IOOtherBytes)
429             SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_SETCHECK, BST_CHECKED, 0);
430
431         return TRUE;
432
433     case WM_COMMAND:
434
435         if (LOWORD(wParam) == IDCANCEL)
436         {
437             EndDialog(hDlg, LOWORD(wParam));
438             return TRUE;
439         }
440
441         if (LOWORD(wParam) == IDOK)
442         {
443             TaskManagerSettings.Column_ImageName = SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0);
444             TaskManagerSettings.Column_PID = SendMessage(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
445             TaskManagerSettings.Column_UserName = SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_GETCHECK, 0, 0);
446             TaskManagerSettings.Column_SessionID = SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
447             TaskManagerSettings.Column_CPUUsage = SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_GETCHECK, 0, 0);
448             TaskManagerSettings.Column_CPUTime = SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
449             TaskManagerSettings.Column_MemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_GETCHECK, 0, 0);
450             TaskManagerSettings.Column_PeakMemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
451             TaskManagerSettings.Column_MemoryUsageDelta = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_GETCHECK, 0, 0);
452             TaskManagerSettings.Column_PageFaults = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
453             TaskManagerSettings.Column_PageFaultsDelta = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_GETCHECK, 0, 0);
454             TaskManagerSettings.Column_VirtualMemorySize = SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
455             TaskManagerSettings.Column_PagedPool = SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_GETCHECK, 0, 0);
456             TaskManagerSettings.Column_NonPagedPool = SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
457             TaskManagerSettings.Column_BasePriority = SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_GETCHECK, 0, 0);
458             TaskManagerSettings.Column_HandleCount = SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
459             TaskManagerSettings.Column_ThreadCount = SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_GETCHECK, 0, 0);
460             TaskManagerSettings.Column_USERObjects = SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
461             TaskManagerSettings.Column_GDIObjects = SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_GETCHECK, 0, 0);
462             TaskManagerSettings.Column_IOReads = SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
463             TaskManagerSettings.Column_IOWrites = SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_GETCHECK, 0, 0);
464             TaskManagerSettings.Column_IOOther = SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
465             TaskManagerSettings.Column_IOReadBytes = SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_GETCHECK, 0, 0);
466             TaskManagerSettings.Column_IOWriteBytes = SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
467             TaskManagerSettings.Column_IOOtherBytes = SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
468
469             EndDialog(hDlg, LOWORD(wParam));
470             return TRUE;
471         }
472
473         break;
474     }
475
476     return 0;
477 }
478
479 void UpdateColumnDataHints(void)
480 {
481     HDITEM            hditem;
482     TCHAR            text[260];
483     ULONG            Index;
484
485     for (Index=0; Index<(ULONG)SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); Index++)
486     {
487         memset(&hditem, 0, sizeof(HDITEM));
488
489         hditem.mask = HDI_TEXT;
490         hditem.pszText = text;
491         hditem.cchTextMax = 260;
492
493         SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, Index, (LPARAM) &hditem);
494
495         if (_tcsicmp(text, _T("Image Name")) == 0)
496             ColumnDataHints[Index] = COLUMN_IMAGENAME;
497         if (_tcsicmp(text, _T("PID")) == 0)
498             ColumnDataHints[Index] = COLUMN_PID;
499         if (_tcsicmp(text, _T("Username")) == 0)
500             ColumnDataHints[Index] = COLUMN_USERNAME;
501         if (_tcsicmp(text, _T("Session ID")) == 0)
502             ColumnDataHints[Index] = COLUMN_SESSIONID;
503         if (_tcsicmp(text, _T("CPU")) == 0)
504             ColumnDataHints[Index] = COLUMN_CPUUSAGE;
505         if (_tcsicmp(text, _T("CPU Time")) == 0)
506             ColumnDataHints[Index] = COLUMN_CPUTIME;
507         if (_tcsicmp(text, _T("Mem Usage")) == 0)
508             ColumnDataHints[Index] = COLUMN_MEMORYUSAGE;
509         if (_tcsicmp(text, _T("Peak Mem Usage")) == 0)
510             ColumnDataHints[Index] = COLUMN_PEAKMEMORYUSAGE;
511         if (_tcsicmp(text, _T("Mem Delta")) == 0)
512             ColumnDataHints[Index] = COLUMN_MEMORYUSAGEDELTA;
513         if (_tcsicmp(text, _T("Page Faults")) == 0)
514             ColumnDataHints[Index] = COLUMN_PAGEFAULTS;
515         if (_tcsicmp(text, _T("PF Delta")) == 0)
516             ColumnDataHints[Index] = COLUMN_PAGEFAULTSDELTA;
517         if (_tcsicmp(text, _T("VM Size")) == 0)
518             ColumnDataHints[Index] = COLUMN_VIRTUALMEMORYSIZE;
519         if (_tcsicmp(text, _T("Paged Pool")) == 0)
520             ColumnDataHints[Index] = COLUMN_PAGEDPOOL;
521         if (_tcsicmp(text, _T("NP Pool")) == 0)
522             ColumnDataHints[Index] = COLUMN_NONPAGEDPOOL;
523         if (_tcsicmp(text, _T("Base Pri")) == 0)
524             ColumnDataHints[Index] = COLUMN_BASEPRIORITY;
525         if (_tcsicmp(text, _T("Handles")) == 0)
526             ColumnDataHints[Index] = COLUMN_HANDLECOUNT;
527         if (_tcsicmp(text, _T("Threads")) == 0)
528             ColumnDataHints[Index] = COLUMN_THREADCOUNT;
529         if (_tcsicmp(text, _T("USER Objects")) == 0)
530             ColumnDataHints[Index] = COLUMN_USEROBJECTS;
531         if (_tcsicmp(text, _T("GDI Objects")) == 0)
532             ColumnDataHints[Index] = COLUMN_GDIOBJECTS;
533         if (_tcsicmp(text, _T("I/O Reads")) == 0)
534             ColumnDataHints[Index] = COLUMN_IOREADS;
535         if (_tcsicmp(text, _T("I/O Writes")) == 0)
536             ColumnDataHints[Index] = COLUMN_IOWRITES;
537         if (_tcsicmp(text, _T("I/O Other")) == 0)
538             ColumnDataHints[Index] = COLUMN_IOOTHER;
539         if (_tcsicmp(text, _T("I/O Read Bytes")) == 0)
540             ColumnDataHints[Index] = COLUMN_IOREADBYTES;
541         if (_tcsicmp(text, _T("I/O Write Bytes")) == 0)
542             ColumnDataHints[Index] = COLUMN_IOWRITEBYTES;
543         if (_tcsicmp(text, _T("I/O Other Bytes")) == 0)
544             ColumnDataHints[Index] = COLUMN_IOOTHERBYTES;
545     }
546 }