taskmgr: Add Japanese resource.
[wine] / programs / taskmgr / perfpage.c
1 /*
2  *  ReactOS Task Manager
3  *
4  *  perfpage.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 #include <winnt.h>
32
33 #include "taskmgr.h"
34 #include "perfdata.h"
35 #include "graphctl.h"
36
37 TGraphCtrl PerformancePageCpuUsageHistoryGraph;
38 TGraphCtrl PerformancePageMemUsageHistoryGraph;
39
40 HWND            hPerformancePage;                                       /*  Performance Property Page */
41 HWND            hPerformancePageCpuUsageGraph;                          /*  CPU Usage Graph */
42 HWND            hPerformancePageMemUsageGraph;                          /*  MEM Usage Graph */
43 HWND            hPerformancePageCpuUsageHistoryGraph;                   /*  CPU Usage History Graph */
44 HWND            hPerformancePageMemUsageHistoryGraph;                   /*  Memory Usage History Graph */
45 HWND            hPerformancePageTotalsFrame;                            /*  Totals Frame */
46 HWND            hPerformancePageCommitChargeFrame;                      /*  Commit Charge Frame */
47 HWND            hPerformancePageKernelMemoryFrame;                      /*  Kernel Memory Frame */
48 HWND            hPerformancePagePhysicalMemoryFrame;                    /*  Physical Memory Frame */
49 HWND            hPerformancePageCpuUsageFrame;
50 HWND            hPerformancePageMemUsageFrame;
51 HWND            hPerformancePageCpuUsageHistoryFrame;
52 HWND            hPerformancePageMemUsageHistoryFrame;
53 HWND            hPerformancePageCommitChargeTotalEdit;                  /*  Commit Charge Total Edit Control */
54 HWND            hPerformancePageCommitChargeLimitEdit;                  /*  Commit Charge Limit Edit Control */
55 HWND            hPerformancePageCommitChargePeakEdit;                   /*  Commit Charge Peak Edit Control */
56 HWND            hPerformancePageKernelMemoryTotalEdit;                  /*  Kernel Memory Total Edit Control */
57 HWND            hPerformancePageKernelMemoryPagedEdit;                  /*  Kernel Memory Paged Edit Control */
58 HWND            hPerformancePageKernelMemoryNonPagedEdit;               /*  Kernel Memory NonPaged Edit Control */
59 HWND            hPerformancePagePhysicalMemoryTotalEdit;                /*  Physical Memory Total Edit Control */
60 HWND            hPerformancePagePhysicalMemoryAvailableEdit;    /*  Physical Memory Available Edit Control */
61 HWND            hPerformancePagePhysicalMemorySystemCacheEdit;  /*  Physical Memory System Cache Edit Control */
62 HWND            hPerformancePageTotalsHandleCountEdit;                  /*  Total Handles Edit Control */
63 HWND            hPerformancePageTotalsProcessCountEdit;                 /*  Total Processes Edit Control */
64 HWND            hPerformancePageTotalsThreadCountEdit;                  /*  Total Threads Edit Control */
65
66
67 static int      nPerformancePageWidth;
68 static int      nPerformancePageHeight;
69 static HANDLE   hPerformancePageEvent = NULL;   /*  When this event becomes signaled then we refresh the performance page */
70
71 static void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
72 {
73     RECT        rc;
74     int         cx, cy, sx, sy;
75
76     GetClientRect(hCntrl, &rc);
77     MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)));
78     if (pos) {
79         cx = rc.left;
80         cy = rc.top;
81         sx = rc.right - rc.left;
82         switch (pos) {
83         case 1:
84             break;
85         case 2:
86             cy += nYDifference / 2;
87             break;
88         case 3:
89             sx += nXDifference;
90             break;
91         case 4:
92             cy += nYDifference / 2;
93             sx += nXDifference;
94             break;
95         }
96         sy = rc.bottom - rc.top + nYDifference / 2;
97         SetWindowPos(hCntrl, NULL, cx, cy, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
98     } else {
99         cx = rc.left + nXDifference;
100         cy = rc.top + nYDifference;
101         sx = sy = 0;
102         SetWindowPos(hCntrl, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
103     }
104     InvalidateRect(hCntrl, NULL, TRUE);
105 }
106                  
107 static void AdjustControlPostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
108 {
109     AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0);
110 }
111                  
112 static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
113 {
114     AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
115 }
116 void RefreshPerformancePage(void)
117 {
118         /*  Signal the event so that our refresh thread */
119         /*  will wake up and refresh the performance page */
120         SetEvent(hPerformancePageEvent);
121 }
122
123 static DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
124 {
125         ULONG   CommitChargeTotal;
126         ULONG   CommitChargeLimit;
127         ULONG   CommitChargePeak;
128
129         ULONG   KernelMemoryTotal;
130         ULONG   KernelMemoryPaged;
131         ULONG   KernelMemoryNonPaged;
132
133         ULONG   PhysicalMemoryTotal;
134         ULONG   PhysicalMemoryAvailable;
135         ULONG   PhysicalMemorySystemCache;
136
137         ULONG   TotalHandles;
138         ULONG   TotalThreads;
139         ULONG   TotalProcesses;
140
141         TCHAR   Text[260];
142
143         /*  Create the event */
144         hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
145
146         /*  If we couldn't create the event then exit the thread */
147         if (!hPerformancePageEvent)
148                 return 0;
149
150         while (1)
151         {
152                 DWORD   dwWaitVal;
153
154                 /*  Wait on the event */
155                 dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE);
156
157                 /*  If the wait failed then the event object must have been */
158                 /*  closed and the task manager is exiting so exit this thread */
159                 if (dwWaitVal == WAIT_FAILED)
160                         return 0;
161
162                 if (dwWaitVal == WAIT_OBJECT_0)
163                 {
164                         ULONG CpuUsage;
165                         ULONG CpuKernelUsage;
166                         int nBarsUsed1;
167                         int nBarsUsed2;
168
169                         /*  Reset our event */
170                         ResetEvent(hPerformancePageEvent);
171
172                         /* 
173                          *  Update the commit charge info
174                          */ 
175                         CommitChargeTotal = PerfDataGetCommitChargeTotalK();
176                         CommitChargeLimit = PerfDataGetCommitChargeLimitK();
177                         CommitChargePeak = PerfDataGetCommitChargePeakK();
178                         _ultoa(CommitChargeTotal, Text, 10);
179                         SetWindowText(hPerformancePageCommitChargeTotalEdit, Text);
180                         _ultoa(CommitChargeLimit, Text, 10);
181                         SetWindowText(hPerformancePageCommitChargeLimitEdit, Text);
182                         _ultoa(CommitChargePeak, Text, 10);
183                         SetWindowText(hPerformancePageCommitChargePeakEdit, Text);
184                         wsprintf(Text, _T("Mem Usage: %dK / %dK"), CommitChargeTotal, CommitChargeLimit);
185                         SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
186
187                         /* 
188                          *  Update the kernel memory info
189                          */ 
190                         KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
191                         KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
192                         KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
193                         _ultoa(KernelMemoryTotal, Text, 10);
194                         SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text);
195                         _ultoa(KernelMemoryPaged, Text, 10);
196                         SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text);
197                         _ultoa(KernelMemoryNonPaged, Text, 10);
198                         SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);
199
200                         /* 
201                          *  Update the physical memory info
202                          */ 
203                         PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
204                         PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
205                         PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
206                         _ultoa(PhysicalMemoryTotal, Text, 10);
207                         SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text);
208                         _ultoa(PhysicalMemoryAvailable, Text, 10);
209                         SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text);
210                         _ultoa(PhysicalMemorySystemCache, Text, 10);
211                         SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
212
213                         /* 
214                          *  Update the totals info
215                          */ 
216                         TotalHandles = PerfDataGetSystemHandleCount();
217                         TotalThreads = PerfDataGetTotalThreadCount();
218                         TotalProcesses = PerfDataGetProcessCount();
219                         _ultoa(TotalHandles, Text, 10);
220                         SetWindowText(hPerformancePageTotalsHandleCountEdit, Text);
221                         _ultoa(TotalThreads, Text, 10);
222                         SetWindowText(hPerformancePageTotalsThreadCountEdit, Text);
223                         _ultoa(TotalProcesses, Text, 10);
224                         SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);
225
226                         /* 
227                          *  Redraw the graphs
228                          */ 
229                         InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
230                         InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
231
232                         /*
233                          *  Get the CPU usage
234                          */
235                         CpuUsage = PerfDataGetProcessorUsage();
236                         CpuKernelUsage = PerfDataGetProcessorSystemUsage();
237                         if (CpuUsage < 0 )        CpuUsage = 0;
238                         if (CpuUsage > 100)       CpuUsage = 100;
239                         if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
240                         if (CpuKernelUsage > 100) CpuKernelUsage = 100;
241
242                         /*
243                          *  Get the memory usage
244                          */
245                         CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
246                         CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
247                         nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
248
249                         PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
250                         PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
251                         nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
252
253
254                         GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
255                         GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
256                         /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
257                         InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
258                         InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
259                 }
260         }
261         return 0;
262 }
263
264 INT_PTR CALLBACK
265 PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
266 {
267         RECT    rc;
268         int             nXDifference;
269         int             nYDifference;
270
271 /*     HDC hdc; */
272 /*     PAINTSTRUCT ps; */
273
274     switch (message) {
275         case WM_INITDIALOG:
276                 
277                 /*  Save the width and height */
278                 GetClientRect(hDlg, &rc);
279                 nPerformancePageWidth = rc.right;
280                 nPerformancePageHeight = rc.bottom;
281
282                 /*  Update window position */
283                 SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
284
285                 /* 
286                  *  Get handles to all the controls
287                  */ 
288                 hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME);
289                 hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME);
290                 hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME);
291                 hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME);
292
293                 hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME);
294                 hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME);
295                 hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME);
296                 hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME);
297
298                 hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL);
299                 hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT);
300                 hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK);
301                 hPerformancePageKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL);
302                 hPerformancePageKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED);
303                 hPerformancePageKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED);
304                 hPerformancePagePhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL);
305                 hPerformancePagePhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE);
306                 hPerformancePagePhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE);
307                 hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT);
308                 hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT);
309                 hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT);
310
311         hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH);
312                 hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH);
313                 hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
314         hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
315                 
316                 GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc);
317         /*  create the control */
318         /* PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); */
319         GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph, hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
320         /*  customize the control */
321         GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph, 0.0, 100.0, 10);
322 /*         PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ; */
323 /*         PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ; */
324 /*         PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ; */
325 /*         PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ; */
326 /*         PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */
327         GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ;
328         GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(152, 205, 152)) ;
329         GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(255, 0, 0)) ;
330         GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(0, 255, 0)) ;
331
332         GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc);
333         GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph, hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
334         GraphCtrl_SetRange(&PerformancePageMemUsageHistoryGraph, 0.0, 100.0, 10) ;
335         GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 0, 0)) ;
336         GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph, RGB(152, 215, 152)) ;
337         GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ;
338                 /*  Start our refresh thread */
339 #ifdef RUN_PERF_PAGE
340         CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL);
341 #endif
342
343                 /* 
344                  *  Subclass graph buttons
345                  */ 
346         OldGraphWndProc = (WNDPROC)SetWindowLongPtr(hPerformancePageCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
347         SetWindowLongPtr(hPerformancePageMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
348         OldGraphCtrlWndProc = (WNDPROC)SetWindowLongPtr(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
349         SetWindowLongPtr(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
350                 return TRUE;
351
352         case WM_COMMAND:
353                 break;
354 #if 0
355     case WM_NCPAINT:
356         hdc = GetDC(hDlg);
357         GetClientRect(hDlg, &rc);
358         Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
359         ReleaseDC(hDlg, hdc);
360         break;
361
362     case WM_PAINT:
363         hdc = BeginPaint(hDlg, &ps);
364         GetClientRect(hDlg, &rc);
365         Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
366         EndPaint(hDlg, &ps);
367         break;
368 #endif
369         case WM_SIZE:
370         do {
371                 int             cx, cy;
372
373                 if (wParam == SIZE_MINIMIZED)
374                         return 0;
375
376                 cx = LOWORD(lParam);
377                 cy = HIWORD(lParam);
378                 nXDifference = cx - nPerformancePageWidth;
379                 nYDifference = cy - nPerformancePageHeight;
380                 nPerformancePageWidth = cx;
381                 nPerformancePageHeight = cy;
382         } while (0);
383
384                 /*  Reposition the performance page's controls */
385         AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0);
386         AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0);
387         AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0);
388         AdjustFrameSize(hPerformancePagePhysicalMemoryFrame, hDlg, 0, nYDifference, 0);
389         AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference);
390         AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference);
391         AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference);
392         AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL, hDlg, 0, nYDifference);
393         AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED, hDlg, 0, nYDifference);
394         AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED, hDlg, 0, nYDifference);
395         AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL, hDlg, 0, nYDifference);
396         AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE, hDlg, 0, nYDifference);
397         AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE, hDlg, 0, nYDifference);
398         AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT, hDlg, 0, nYDifference);
399         AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference);
400         AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference);
401
402         AdjustControlPostion(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference);
403         AdjustControlPostion(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference);
404         AdjustControlPostion(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference);
405         AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference);
406         AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference);
407         AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference);
408         AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference);
409         AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference);
410         AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference);
411         AdjustControlPostion(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference);
412         AdjustControlPostion(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference);
413         AdjustControlPostion(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference);
414
415         {
416             static int lastX, lastY;
417
418             nXDifference += lastX;
419             nYDifference += lastY;
420             lastX = lastY = 0;
421             if (nXDifference % 2) {
422                 if (nXDifference > 0) {
423                     nXDifference--;
424                     lastX++;
425                 } else {
426                     nXDifference++;
427                     lastX--;
428                 }
429             }
430             if (nYDifference % 2) {
431                 if (nYDifference > 0) {
432                     nYDifference--;
433                     lastY++;
434                 } else {
435                     nYDifference++;
436                     lastY--;
437                 }
438             }
439         }
440
441         AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1);
442         AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2);
443         AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3);
444         AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4);
445         AdjustFrameSize(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1);
446         AdjustFrameSize(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2);
447         AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3);
448         AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4);
449                 break;
450         }
451     return 0;
452 }
453
454 void PerformancePage_OnViewShowKernelTimes(void)
455 {
456         HMENU   hMenu;
457         HMENU   hViewMenu;
458
459         hMenu = GetMenu(hMainWnd);
460         hViewMenu = GetSubMenu(hMenu, 2);
461
462         /*  Check or uncheck the show 16-bit tasks menu item */
463         if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED)
464         {
465                 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);
466                 TaskManagerSettings.ShowKernelTimes = FALSE;
467         }
468         else
469         {
470                 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
471                 TaskManagerSettings.ShowKernelTimes = TRUE;
472         }
473
474         RefreshPerformancePage();
475 }
476
477 void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
478 {
479         HMENU   hMenu;
480         HMENU   hViewMenu;
481         HMENU   hCPUHistoryMenu;
482
483         hMenu = GetMenu(hMainWnd);
484         hViewMenu = GetSubMenu(hMenu, 2);
485         hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
486
487         TaskManagerSettings.CPUHistory_OneGraphPerCPU = FALSE;
488         CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND);
489 }
490
491 void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
492 {
493         HMENU   hMenu;
494         HMENU   hViewMenu;
495         HMENU   hCPUHistoryMenu;
496
497         hMenu = GetMenu(hMainWnd);
498         hViewMenu = GetSubMenu(hMenu, 2);
499         hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
500
501         TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
502         CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);
503 }