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