taskmgr: Make remaining strings translatable.
[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     WCHAR    wszCPU_Usage[255];
390     WCHAR    wszProcesses[255];
391
392     LoadStringW(hInst, IDS_STATUS_BAR_CPU_USAGE, wszCPU_Usage, sizeof(wszCPU_Usage)/sizeof(WCHAR));
393     LoadStringW(hInst, IDS_STATUS_BAR_PROCESSES, wszProcesses, sizeof(wszProcesses)/sizeof(WCHAR));
394
395     /* Create the event */
396     hProcessPageEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
397
398     /* If we couldn't create the event then exit the thread */
399     if (!hProcessPageEvent)
400         return 0;
401
402     while (1) {
403         DWORD    dwWaitVal;
404
405         /* Wait on the event */
406         dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE);
407
408         /* If the wait failed then the event object must have been */
409         /* closed and the task manager is exiting so exit this thread */
410         if (dwWaitVal == WAIT_FAILED)
411             return 0;
412
413         if (dwWaitVal == WAIT_OBJECT_0) {
414             WCHAR    text[256];
415
416             /* Reset our event */
417             ResetEvent(hProcessPageEvent);
418
419             if ((ULONG)SendMessage(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount())
420                 SendMessage(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL);
421
422             if (IsWindowVisible(hProcessPage))
423                 InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
424
425             if (OldProcessorUsage != PerfDataGetProcessorUsage()) {
426                 OldProcessorUsage = PerfDataGetProcessorUsage();
427                 wsprintfW(text, wszCPU_Usage, OldProcessorUsage);
428                 SendMessageW(hStatusWnd, SB_SETTEXTW, 1, (LPARAM)text);
429             }
430             if (OldProcessCount != PerfDataGetProcessCount()) {
431                 OldProcessCount = PerfDataGetProcessCount();
432                 wsprintfW(text, wszProcesses, OldProcessCount);
433                 SendMessageW(hStatusWnd, SB_SETTEXTW, 0, (LPARAM)text);
434             }
435         }
436     }
437         return 0;
438 }
439
440 INT_PTR CALLBACK
441 ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
442 {
443     RECT    rc;
444     int        nXDifference;
445     int        nYDifference;
446     int        cx, cy;
447
448     switch (message) {
449     case WM_INITDIALOG:
450         /*
451          * Save the width and height
452          */
453         GetClientRect(hDlg, &rc);
454         nProcessPageWidth = rc.right;
455         nProcessPageHeight = rc.bottom;
456
457         /* Update window position */
458         SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
459
460         /*
461          * Get handles to the controls
462          */
463         hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST);
464         hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl);
465         hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS);
466         hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES);
467
468         /*
469          * Set the extended window styles for the list control
470          */
471         SendMessage(hProcessPageListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
472
473         AddColumns();
474
475         /*
476          * Subclass the process list control so we can intercept WM_ERASEBKGND
477          */
478         OldProcessListWndProc = (WNDPROC)SetWindowLongPtr(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc);
479
480         /* Start our refresh thread */
481          CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
482
483         return TRUE;
484
485     case WM_DESTROY:
486         /* Close the event handle, this will make the */
487         /* refresh thread exit when the wait fails */
488         CloseHandle(hProcessPageEvent);
489
490         SaveColumnSettings();
491
492         break;
493
494     case WM_COMMAND:
495         /* Handle the button clicks */
496         switch (LOWORD(wParam))
497         {
498                 case IDC_ENDPROCESS:
499                         ProcessPage_OnEndProcess();
500         }
501         break;
502
503     case WM_SIZE:
504         if (wParam == SIZE_MINIMIZED)
505             return 0;
506
507         cx = LOWORD(lParam);
508         cy = HIWORD(lParam);
509         nXDifference = cx - nProcessPageWidth;
510         nYDifference = cy - nProcessPageHeight;
511         nProcessPageWidth = cx;
512         nProcessPageHeight = cy;
513
514         /* Reposition the application page's controls */
515         GetWindowRect(hProcessPageListCtrl, &rc);
516         cx = (rc.right - rc.left) + nXDifference;
517         cy = (rc.bottom - rc.top) + nYDifference;
518         SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
519         InvalidateRect(hProcessPageListCtrl, NULL, TRUE);
520         
521         GetClientRect(hProcessPageEndProcessButton, &rc);
522         MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
523            cx = rc.left + nXDifference;
524         cy = rc.top + nYDifference;
525         SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
526         InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE);
527         
528         GetClientRect(hProcessPageShowAllProcessesButton, &rc);
529         MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
530            cx = rc.left;
531         cy = rc.top + nYDifference;
532         SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
533         InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE);
534
535         break;
536
537     case WM_NOTIFY:
538
539         ProcessPageOnNotify(wParam, lParam);
540         break;
541     }
542
543     return 0;
544 }