wined3d: Pack hardcoded local constants in ARB.
[wine] / programs / taskmgr / procpage.c
1 /*
2  *  ReactOS Task Manager
3  *
4  *  procpage.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 <memory.h>
28 #include <tchar.h>
29 #include <stdio.h>
30 #include <winnt.h>
31     
32 #include "taskmgr.h"
33 #include "perfdata.h"
34 #include "column.h"
35 #include <ctype.h>
36
37 HWND hProcessPage;                        /* Process List Property Page */
38
39 HWND hProcessPageListCtrl;                /* Process ListCtrl Window */
40 HWND hProcessPageHeaderCtrl;            /* Process Header Control */
41 HWND hProcessPageEndProcessButton;        /* Process End Process button */
42 HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */
43
44 static int    nProcessPageWidth;
45 static int    nProcessPageHeight;
46
47 static HANDLE    hProcessPageEvent = NULL;    /* When this event becomes signaled then we refresh the process list */
48
49
50 static void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount)
51 {
52     TCHAR    temp[260];
53     UINT    i, j, k;
54
55     for (i=0,j=0; i<(_tcslen(strNumber) % 3); i++, j++)
56         temp[j] = strNumber[i];
57     for (k=0; i<_tcslen(strNumber); i++,j++,k++) {
58         if ((k % 3 == 0) && (j > 0))
59             temp[j++] = _T(',');
60         temp[j] = strNumber[i];
61     }
62     temp[j] = _T('\0');
63     _tcsncpy(strNumber, temp, nMaxCount);
64 }
65
66 static void ProcessPageShowContextMenu(DWORD dwProcessId)
67 {
68     HMENU        hMenu;
69     HMENU        hSubMenu;
70     HMENU        hPriorityMenu;
71     POINT        pt;
72     SYSTEM_INFO    si;
73     HANDLE        hProcess;
74     DWORD        dwProcessPriorityClass;
75     TCHAR        strDebugger[260];
76     DWORD        dwDebuggerSize;
77     HKEY        hKey;
78     UINT        Idx;
79
80     memset(&si, 0, sizeof(SYSTEM_INFO));
81
82     GetCursorPos(&pt);
83     GetSystemInfo(&si);
84
85     hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PROCESS_PAGE_CONTEXT));
86     hSubMenu = GetSubMenu(hMenu, 0);
87     hPriorityMenu = GetSubMenu(hSubMenu, 4);
88
89     hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
90     dwProcessPriorityClass = GetPriorityClass(hProcess);
91     CloseHandle(hProcess);
92
93     if (si.dwNumberOfProcessors < 2)
94         RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);
95     
96     if (!AreDebugChannelsSupported())
97         RemoveMenu(hSubMenu, ID_PROCESS_PAGE_DEBUGCHANNELS, MF_BYCOMMAND);
98
99     switch (dwProcessPriorityClass)    {
100     case REALTIME_PRIORITY_CLASS:
101         CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND);
102         break;
103     case HIGH_PRIORITY_CLASS:
104         CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND);
105         break;
106     case ABOVE_NORMAL_PRIORITY_CLASS:
107         CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND);
108         break;
109     case NORMAL_PRIORITY_CLASS:
110         CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND);
111         break;
112     case BELOW_NORMAL_PRIORITY_CLASS:
113         CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND);
114         break;
115     case IDLE_PRIORITY_CLASS:
116         CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND);
117         break;
118     }
119
120     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
121     {
122         dwDebuggerSize = 260;
123         if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
124         {
125             for (Idx=0; Idx<_tcslen(strDebugger); Idx++)
126                 strDebugger[Idx] = toupper(strDebugger[Idx]);
127
128             if (_tcsstr(strDebugger, _T("DRWTSN32")))
129                 EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
130         }
131         else
132             EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
133
134         RegCloseKey(hKey);
135     } else {
136         EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
137     }
138     TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);
139     DestroyMenu(hMenu);
140 }
141
142 static void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
143 {
144     int                idctrl;
145     LPNMHDR            pnmh;
146     LPNMLISTVIEW    pnmv;
147     NMLVDISPINFO*    pnmdi;
148     LPNMHEADER        pnmhdr;
149     LVITEM            lvitem;
150     ULONG            Index;
151     ULONG            ColumnIndex;
152     IO_COUNTERS        iocounters;
153     TIME            time;
154
155     idctrl = (int) wParam;
156     pnmh = (LPNMHDR) lParam;
157     pnmv = (LPNMLISTVIEW) lParam;
158     pnmdi = (NMLVDISPINFO*) lParam;
159     pnmhdr = (LPNMHEADER) lParam;
160
161     if (pnmh->hwndFrom == hProcessPageListCtrl)
162     {
163         switch (pnmh->code)
164         {
165 #if 0
166         case LVN_ITEMCHANGED:
167             ProcessPageUpdate();
168             break;
169 #endif
170             
171         case LVN_GETDISPINFO:
172
173             if (!(pnmdi->item.mask & LVIF_TEXT))
174                 break;
175             
176             ColumnIndex = pnmdi->item.iSubItem;
177             Index = pnmdi->item.iItem;
178
179             if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME)
180                 PerfDataGetImageName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax);
181             if (ColumnDataHints[ColumnIndex] == COLUMN_PID)
182                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetProcessId(Index));
183             if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME)
184                 PerfDataGetUserName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax);
185             if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID)
186                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetSessionId(Index));
187             if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE)
188                 wsprintf(pnmdi->item.pszText, _T("%02d"), PerfDataGetCPUUsage(Index));
189             if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME)
190             {
191                 DWORD dwHours;
192                 DWORD dwMinutes;
193                 DWORD dwSeconds;
194                 ULONGLONG secs;
195
196                 time = PerfDataGetCPUTime(Index);
197                 secs = time.QuadPart / 10000000;
198                 dwHours = secs / 3600;
199                 dwMinutes = (secs % 3600) / 60;
200                 dwSeconds = (secs % 3600) % 60;
201                 wsprintf(pnmdi->item.pszText, _T("%d:%02d:%02d"), dwHours, dwMinutes, dwSeconds);
202             }
203             if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE)
204             {
205                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeBytes(Index) / 1024);
206                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
207                 _tcscat(pnmdi->item.pszText, _T(" K"));
208             }
209             if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE)
210             {
211                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024);
212                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
213                 _tcscat(pnmdi->item.pszText, _T(" K"));
214             }
215             if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA)
216             {
217                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeDelta(Index) / 1024);
218                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
219                 _tcscat(pnmdi->item.pszText, _T(" K"));
220             }
221             if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS)
222             {
223                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCount(Index));
224                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
225             }
226             if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA)
227             {
228                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCountDelta(Index));
229                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
230             }
231             if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE)
232             {
233                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetVirtualMemorySizeBytes(Index) / 1024);
234                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
235                 _tcscat(pnmdi->item.pszText, _T(" K"));
236             }
237             if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL)
238             {
239                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPagedPoolUsagePages(Index) / 1024);
240                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
241                 _tcscat(pnmdi->item.pszText, _T(" K"));
242             }
243             if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL)
244             {
245                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetNonPagedPoolUsagePages(Index) / 1024);
246                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
247                 _tcscat(pnmdi->item.pszText, _T(" K"));
248             }
249             if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY)
250                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetBasePriority(Index));
251             if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT)
252             {
253                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetHandleCount(Index));
254                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
255             }
256             if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT)
257             {
258                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetThreadCount(Index));
259                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
260             }
261             if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS)
262             {
263                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetUSERObjectCount(Index));
264                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
265             }
266             if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS)
267             {
268                 wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetGDIObjectCount(Index));
269                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
270             }
271             if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS)
272             {
273                 PerfDataGetIOCounters(Index, &iocounters);
274                 /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadOperationCount); */
275 #ifdef UNICODE
276 #define _ui64toa _ui64tow
277 #else
278 #endif
279                 _ui64toa(iocounters.ReadOperationCount, pnmdi->item.pszText, 10);
280                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
281             }
282             if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES)
283             {
284                 PerfDataGetIOCounters(Index, &iocounters);
285                 /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteOperationCount); */
286                 _ui64toa(iocounters.WriteOperationCount, pnmdi->item.pszText, 10);
287                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
288             }
289             if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER)
290             {
291                 PerfDataGetIOCounters(Index, &iocounters);
292                 /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherOperationCount); */
293                 _ui64toa(iocounters.OtherOperationCount, pnmdi->item.pszText, 10);
294                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
295             }
296             if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES)
297             {
298                 PerfDataGetIOCounters(Index, &iocounters);
299                 /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadTransferCount); */
300                 _ui64toa(iocounters.ReadTransferCount, pnmdi->item.pszText, 10);
301                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
302             }
303             if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES)
304             {
305                 PerfDataGetIOCounters(Index, &iocounters);
306                 /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteTransferCount); */
307                 _ui64toa(iocounters.WriteTransferCount, pnmdi->item.pszText, 10);
308                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
309             }
310             if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES)
311             {
312                 PerfDataGetIOCounters(Index, &iocounters);
313                 /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherTransferCount); */
314                 _ui64toa(iocounters.OtherTransferCount, pnmdi->item.pszText, 10);
315                 CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
316             }
317
318             break;
319
320         case NM_RCLICK:
321
322             for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
323             {
324                 lvitem.mask = LVIF_STATE;
325                 lvitem.stateMask = LVIS_SELECTED;
326                 lvitem.iItem = Index;
327                 lvitem.iSubItem = 0;
328
329                 SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);
330
331                 if (lvitem.state & LVIS_SELECTED)
332                     break;
333             }
334
335             if ((ListView_GetSelectedCount(hProcessPageListCtrl) == 1) &&
336                 (PerfDataGetProcessId(Index) != 0))
337             {
338                 ProcessPageShowContextMenu(PerfDataGetProcessId(Index));
339             }
340
341             break;
342
343         }
344     }
345     else if (pnmh->hwndFrom == hProcessPageHeaderCtrl)
346     {
347         switch (pnmh->code)
348         {
349         case HDN_ITEMCLICK:
350
351             /*
352              * FIXME: Fix the column sorting
353              *
354              *ListView_SortItems(hApplicationPageListCtrl, ApplicationPageCompareFunc, NULL);
355              *bSortAscending = !bSortAscending;
356              */
357
358             break;
359
360         case HDN_ITEMCHANGED:
361
362             UpdateColumnDataHints();
363
364             break;
365
366         case HDN_ENDDRAG:
367
368             UpdateColumnDataHints();
369
370             break;
371
372         }
373     }
374
375 }
376
377 void RefreshProcessPage(void)
378 {
379     /* Signal the event so that our refresh thread */
380     /* will wake up and refresh the process page */
381     SetEvent(hProcessPageEvent);
382 }
383
384 static DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
385 {
386     ULONG    OldProcessorUsage = 0;
387     ULONG    OldProcessCount = 0;
388
389     /* Create the event */
390     hProcessPageEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
391
392     /* If we couldn't create the event then exit the thread */
393     if (!hProcessPageEvent)
394         return 0;
395
396     while (1) {
397         DWORD    dwWaitVal;
398
399         /* Wait on the event */
400         dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE);
401
402         /* If the wait failed then the event object must have been */
403         /* closed and the task manager is exiting so exit this thread */
404         if (dwWaitVal == WAIT_FAILED)
405             return 0;
406
407         if (dwWaitVal == WAIT_OBJECT_0) {
408             TCHAR    text[260];
409
410             /* Reset our event */
411             ResetEvent(hProcessPageEvent);
412
413             if ((ULONG)SendMessage(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount())
414                 SendMessage(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL);
415
416             if (IsWindowVisible(hProcessPage))
417                 InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
418
419             if (OldProcessorUsage != PerfDataGetProcessorUsage()) {
420                 OldProcessorUsage = PerfDataGetProcessorUsage();
421                 wsprintf(text, _T("CPU Usage: %3d%%"), OldProcessorUsage);
422                 SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
423             }
424             if (OldProcessCount != PerfDataGetProcessCount()) {
425                 OldProcessCount = PerfDataGetProcessCount();
426                 wsprintf(text, _T("Processes: %d"), OldProcessCount);
427                 SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
428             }
429         }
430     }
431         return 0;
432 }
433
434 INT_PTR CALLBACK
435 ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
436 {
437     RECT    rc;
438     int        nXDifference;
439     int        nYDifference;
440     int        cx, cy;
441
442     switch (message) {
443     case WM_INITDIALOG:
444         /*
445          * Save the width and height
446          */
447         GetClientRect(hDlg, &rc);
448         nProcessPageWidth = rc.right;
449         nProcessPageHeight = rc.bottom;
450
451         /* Update window position */
452         SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
453
454         /*
455          * Get handles to the controls
456          */
457         hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST);
458         hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl);
459         hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS);
460         hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES);
461
462         /*
463          * Set the title and extended window styles for the list control
464          */
465         SetWindowText(hProcessPageListCtrl, _T("Processes"));
466         SendMessage(hProcessPageListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
467
468         AddColumns();
469
470         /*
471          * Subclass the process list control so we can intercept WM_ERASEBKGND
472          */
473         OldProcessListWndProc = (WNDPROC)SetWindowLongPtr(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc);
474
475         /* Start our refresh thread */
476          CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
477
478         return TRUE;
479
480     case WM_DESTROY:
481         /* Close the event handle, this will make the */
482         /* refresh thread exit when the wait fails */
483         CloseHandle(hProcessPageEvent);
484
485         SaveColumnSettings();
486
487         break;
488
489     case WM_COMMAND:
490         /* Handle the button clicks */
491         switch (LOWORD(wParam))
492         {
493                 case IDC_ENDPROCESS:
494                         ProcessPage_OnEndProcess();
495         }
496         break;
497
498     case WM_SIZE:
499         if (wParam == SIZE_MINIMIZED)
500             return 0;
501
502         cx = LOWORD(lParam);
503         cy = HIWORD(lParam);
504         nXDifference = cx - nProcessPageWidth;
505         nYDifference = cy - nProcessPageHeight;
506         nProcessPageWidth = cx;
507         nProcessPageHeight = cy;
508
509         /* Reposition the application page's controls */
510         GetWindowRect(hProcessPageListCtrl, &rc);
511         cx = (rc.right - rc.left) + nXDifference;
512         cy = (rc.bottom - rc.top) + nYDifference;
513         SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
514         InvalidateRect(hProcessPageListCtrl, NULL, TRUE);
515         
516         GetClientRect(hProcessPageEndProcessButton, &rc);
517         MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
518            cx = rc.left + nXDifference;
519         cy = rc.top + nYDifference;
520         SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
521         InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE);
522         
523         GetClientRect(hProcessPageShowAllProcessesButton, &rc);
524         MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
525            cx = rc.left;
526         cy = rc.top + nYDifference;
527         SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
528         InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE);
529
530         break;
531
532     case WM_NOTIFY:
533
534         ProcessPageOnNotify(wParam, lParam);
535         break;
536     }
537
538     return 0;
539 }