regedit: Update the French translation.
[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
238                         /*
239                          *  Get the memory usage
240                          */
241                         CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
242                         CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
243                         nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
244
245                         PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
246                         PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
247                         nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
248
249
250                         GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
251                         GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
252                         /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
253                         InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
254                         InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
255                 }
256         }
257         return 0;
258 }
259
260 INT_PTR CALLBACK
261 PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
262 {
263         RECT    rc;
264         int             nXDifference;
265         int             nYDifference;
266
267 /*     HDC hdc; */
268 /*     PAINTSTRUCT ps; */
269
270     switch (message) {
271         case WM_INITDIALOG:
272                 
273                 /*  Save the width and height */
274                 GetClientRect(hDlg, &rc);
275                 nPerformancePageWidth = rc.right;
276                 nPerformancePageHeight = rc.bottom;
277
278                 /*  Update window position */
279                 SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
280
281                 /* 
282                  *  Get handles to all the controls
283                  */ 
284                 hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME);
285                 hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME);
286                 hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME);
287                 hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME);
288
289                 hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME);
290                 hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME);
291                 hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME);
292                 hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME);
293
294                 hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL);
295                 hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT);
296                 hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK);
297                 hPerformancePageKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL);
298                 hPerformancePageKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED);
299                 hPerformancePageKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED);
300                 hPerformancePagePhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL);
301                 hPerformancePagePhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE);
302                 hPerformancePagePhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE);
303                 hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT);
304                 hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT);
305                 hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT);
306
307         hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH);
308                 hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH);
309                 hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
310         hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
311                 
312                 GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc);
313         /*  create the control */
314         /* PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); */
315         GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph, hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
316         /*  customize the control */
317         GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph, 0.0, 100.0, 10);
318 /*         PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ; */
319 /*         PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ; */
320 /*         PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ; */
321 /*         PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ; */
322 /*         PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */
323         GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ;
324         GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(152, 205, 152)) ;
325         GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(255, 0, 0)) ;
326         GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(0, 255, 0)) ;
327
328         GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc);
329         GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph, hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
330         GraphCtrl_SetRange(&PerformancePageMemUsageHistoryGraph, 0.0, 100.0, 10) ;
331         GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 0, 0)) ;
332         GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph, RGB(152, 215, 152)) ;
333         GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ;
334                 /*  Start our refresh thread */
335 #ifdef RUN_PERF_PAGE
336         CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL);
337 #endif
338
339                 /* 
340                  *  Subclass graph buttons
341                  */ 
342         OldGraphWndProc = (WNDPROC)SetWindowLongPtr(hPerformancePageCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
343         SetWindowLongPtr(hPerformancePageMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
344         OldGraphCtrlWndProc = (WNDPROC)SetWindowLongPtr(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
345         SetWindowLongPtr(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
346                 return TRUE;
347
348         case WM_COMMAND:
349                 break;
350 #if 0
351     case WM_NCPAINT:
352         hdc = GetDC(hDlg);
353         GetClientRect(hDlg, &rc);
354         Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
355         ReleaseDC(hDlg, hdc);
356         break;
357
358     case WM_PAINT:
359         hdc = BeginPaint(hDlg, &ps);
360         GetClientRect(hDlg, &rc);
361         Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
362         EndPaint(hDlg, &ps);
363         break;
364 #endif
365         case WM_SIZE:
366         do {
367                 int             cx, cy;
368
369                 if (wParam == SIZE_MINIMIZED)
370                         return 0;
371
372                 cx = LOWORD(lParam);
373                 cy = HIWORD(lParam);
374                 nXDifference = cx - nPerformancePageWidth;
375                 nYDifference = cy - nPerformancePageHeight;
376                 nPerformancePageWidth = cx;
377                 nPerformancePageHeight = cy;
378         } while (0);
379
380                 /*  Reposition the performance page's controls */
381         AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0);
382         AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0);
383         AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0);
384         AdjustFrameSize(hPerformancePagePhysicalMemoryFrame, hDlg, 0, nYDifference, 0);
385         AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference);
386         AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference);
387         AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference);
388         AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL, hDlg, 0, nYDifference);
389         AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED, hDlg, 0, nYDifference);
390         AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED, hDlg, 0, nYDifference);
391         AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL, hDlg, 0, nYDifference);
392         AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE, hDlg, 0, nYDifference);
393         AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE, hDlg, 0, nYDifference);
394         AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT, hDlg, 0, nYDifference);
395         AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference);
396         AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference);
397
398         AdjustControlPostion(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference);
399         AdjustControlPostion(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference);
400         AdjustControlPostion(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference);
401         AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference);
402         AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference);
403         AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference);
404         AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference);
405         AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference);
406         AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference);
407         AdjustControlPostion(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference);
408         AdjustControlPostion(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference);
409         AdjustControlPostion(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference);
410
411         {
412             static int lastX, lastY;
413
414             nXDifference += lastX;
415             nYDifference += lastY;
416             lastX = lastY = 0;
417             if (nXDifference % 2) {
418                 if (nXDifference > 0) {
419                     nXDifference--;
420                     lastX++;
421                 } else {
422                     nXDifference++;
423                     lastX--;
424                 }
425             }
426             if (nYDifference % 2) {
427                 if (nYDifference > 0) {
428                     nYDifference--;
429                     lastY++;
430                 } else {
431                     nYDifference++;
432                     lastY--;
433                 }
434             }
435         }
436
437         AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1);
438         AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2);
439         AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3);
440         AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4);
441         AdjustFrameSize(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1);
442         AdjustFrameSize(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2);
443         AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3);
444         AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4);
445                 break;
446         }
447     return 0;
448 }
449
450 void PerformancePage_OnViewShowKernelTimes(void)
451 {
452         HMENU   hMenu;
453         HMENU   hViewMenu;
454
455         hMenu = GetMenu(hMainWnd);
456         hViewMenu = GetSubMenu(hMenu, 2);
457
458         /*  Check or uncheck the show 16-bit tasks menu item */
459         if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED)
460         {
461                 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);
462                 TaskManagerSettings.ShowKernelTimes = FALSE;
463         }
464         else
465         {
466                 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
467                 TaskManagerSettings.ShowKernelTimes = TRUE;
468         }
469
470         RefreshPerformancePage();
471 }
472
473 void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
474 {
475         HMENU   hMenu;
476         HMENU   hViewMenu;
477         HMENU   hCPUHistoryMenu;
478
479         hMenu = GetMenu(hMainWnd);
480         hViewMenu = GetSubMenu(hMenu, 2);
481         hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
482
483         TaskManagerSettings.CPUHistory_OneGraphPerCPU = FALSE;
484         CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND);
485 }
486
487 void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
488 {
489         HMENU   hMenu;
490         HMENU   hViewMenu;
491         HMENU   hCPUHistoryMenu;
492
493         hMenu = GetMenu(hMainWnd);
494         hViewMenu = GetSubMenu(hMenu, 2);
495         hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
496
497         TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
498         CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);
499 }