push cc8bc80451cc24f4d7cf75168b569f0ebfe19547
[wine/hacks.git] / programs / taskmgr / perfpage.c
blobe5f143592b17a07d4733ad487f94d6ad774cfdc4
1 /*
2 * ReactOS Task Manager
4 * perfpage.c
6 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
7 * Copyright (C) 2008 Vladimir Pankratov
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
25 #include <windows.h>
26 #include <commctrl.h>
27 #include <stdlib.h>
28 #include <memory.h>
29 #include <stdio.h>
30 #include <winnt.h>
32 #include "wine/unicode.h"
33 #include "taskmgr.h"
34 #include "perfdata.h"
35 #include "graphctl.h"
37 TGraphCtrl PerformancePageCpuUsageHistoryGraph;
38 TGraphCtrl PerformancePageMemUsageHistoryGraph;
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 */
67 static int nPerformancePageWidth;
68 static int nPerformancePageHeight;
69 static HANDLE hPerformancePageEvent = NULL; /* When this event becomes signaled then we refresh the performance page */
71 static void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
73 RECT rc;
74 int cx, cy, sx, sy;
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;
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);
104 InvalidateRect(hCntrl, NULL, TRUE);
107 static void AdjustControlPostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
109 AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0);
112 static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
114 AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
116 void RefreshPerformancePage(void)
118 /* Signal the event so that our refresh thread */
119 /* will wake up and refresh the performance page */
120 SetEvent(hPerformancePageEvent);
123 static DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
125 ULONG CommitChargeTotal;
126 ULONG CommitChargeLimit;
127 ULONG CommitChargePeak;
129 ULONG KernelMemoryTotal;
130 ULONG KernelMemoryPaged;
131 ULONG KernelMemoryNonPaged;
133 ULONG PhysicalMemoryTotal;
134 ULONG PhysicalMemoryAvailable;
135 ULONG PhysicalMemorySystemCache;
137 ULONG TotalHandles;
138 ULONG TotalThreads;
139 ULONG TotalProcesses;
141 WCHAR Text[256];
143 static const WCHAR wszFormatDigit[] = {'%','d',0};
144 static const WCHAR wszMemUsage[] = {'M','e','m',' ','U','s','a','g','e',':',' ',
145 '%','d','K',' ','/',' ','%','d','K',0};
147 /* Create the event */
148 hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
150 /* If we couldn't create the event then exit the thread */
151 if (!hPerformancePageEvent)
152 return 0;
154 while (1)
156 DWORD dwWaitVal;
158 /* Wait on the event */
159 dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE);
161 /* If the wait failed then the event object must have been */
162 /* closed and the task manager is exiting so exit this thread */
163 if (dwWaitVal == WAIT_FAILED)
164 return 0;
166 if (dwWaitVal == WAIT_OBJECT_0)
168 ULONG CpuUsage;
169 ULONG CpuKernelUsage;
170 int nBarsUsed1;
171 int nBarsUsed2;
173 /* Reset our event */
174 ResetEvent(hPerformancePageEvent);
177 * Update the commit charge info
179 CommitChargeTotal = PerfDataGetCommitChargeTotalK();
180 CommitChargeLimit = PerfDataGetCommitChargeLimitK();
181 CommitChargePeak = PerfDataGetCommitChargePeakK();
182 wsprintfW(Text, wszFormatDigit, CommitChargeTotal);
183 SetWindowTextW(hPerformancePageCommitChargeTotalEdit, Text);
184 wsprintfW(Text, wszFormatDigit, CommitChargeLimit);
185 SetWindowTextW(hPerformancePageCommitChargeLimitEdit, Text);
186 wsprintfW(Text, wszFormatDigit, CommitChargePeak);
187 SetWindowTextW(hPerformancePageCommitChargePeakEdit, Text);
188 wsprintfW(Text, wszMemUsage, CommitChargeTotal, CommitChargeLimit);
189 SendMessageW(hStatusWnd, SB_SETTEXTW, 2, (LPARAM)Text);
192 * Update the kernel memory info
194 KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
195 KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
196 KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
197 wsprintfW(Text, wszFormatDigit, KernelMemoryTotal);
198 SetWindowTextW(hPerformancePageKernelMemoryTotalEdit, Text);
199 wsprintfW(Text, wszFormatDigit, KernelMemoryPaged);
200 SetWindowTextW(hPerformancePageKernelMemoryPagedEdit, Text);
201 wsprintfW(Text, wszFormatDigit, KernelMemoryNonPaged);
202 SetWindowTextW(hPerformancePageKernelMemoryNonPagedEdit, Text);
205 * Update the physical memory info
207 PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
208 PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
209 PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
210 wsprintfW(Text, wszFormatDigit, PhysicalMemoryTotal);
211 SetWindowTextW(hPerformancePagePhysicalMemoryTotalEdit, Text);
212 wsprintfW(Text, wszFormatDigit, PhysicalMemoryAvailable);
213 SetWindowTextW(hPerformancePagePhysicalMemoryAvailableEdit, Text);
214 wsprintfW(Text, wszFormatDigit, PhysicalMemorySystemCache);
215 SetWindowTextW(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
218 * Update the totals info
220 TotalHandles = PerfDataGetSystemHandleCount();
221 TotalThreads = PerfDataGetTotalThreadCount();
222 TotalProcesses = PerfDataGetProcessCount();
223 wsprintfW(Text, wszFormatDigit, TotalHandles);
224 SetWindowTextW(hPerformancePageTotalsHandleCountEdit, Text);
225 wsprintfW(Text, wszFormatDigit, TotalThreads);
226 SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text);
227 wsprintfW(Text, wszFormatDigit, TotalProcesses);
228 SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text);
231 * Redraw the graphs
233 InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
234 InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
237 * Get the CPU usage
239 CpuUsage = PerfDataGetProcessorUsage();
240 CpuKernelUsage = PerfDataGetProcessorSystemUsage();
243 * Get the memory usage
245 CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
246 CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
247 nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
249 PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
250 PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
251 nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
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);
261 return 0;
264 INT_PTR CALLBACK
265 PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
267 RECT rc;
268 int nXDifference;
269 int nYDifference;
271 /* HDC hdc; */
272 /* PAINTSTRUCT ps; */
274 switch (message) {
275 case WM_INITDIALOG:
277 /* Save the width and height */
278 GetClientRect(hDlg, &rc);
279 nPerformancePageWidth = rc.right;
280 nPerformancePageHeight = rc.bottom;
282 /* Update window position */
283 SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
286 * Get handles to all the controls
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);
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);
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);
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);
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)) ;
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
344 * Subclass graph buttons
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;
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;
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;
373 if (wParam == SIZE_MINIMIZED)
374 return 0;
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);
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);
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);
416 static int lastX, lastY;
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--;
430 if (nYDifference % 2) {
431 if (nYDifference > 0) {
432 nYDifference--;
433 lastY++;
434 } else {
435 nYDifference++;
436 lastY--;
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;
451 return 0;
454 void PerformancePage_OnViewShowKernelTimes(void)
456 HMENU hMenu;
457 HMENU hViewMenu;
459 hMenu = GetMenu(hMainWnd);
460 hViewMenu = GetSubMenu(hMenu, 2);
462 /* Check or uncheck the show 16-bit tasks menu item */
463 if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED)
465 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);
466 TaskManagerSettings.ShowKernelTimes = FALSE;
468 else
470 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
471 TaskManagerSettings.ShowKernelTimes = TRUE;
474 RefreshPerformancePage();
477 void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
479 HMENU hMenu;
480 HMENU hViewMenu;
481 HMENU hCPUHistoryMenu;
483 hMenu = GetMenu(hMainWnd);
484 hViewMenu = GetSubMenu(hMenu, 2);
485 hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
487 TaskManagerSettings.CPUHistory_OneGraphPerCPU = FALSE;
488 CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND);
491 void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
493 HMENU hMenu;
494 HMENU hViewMenu;
495 HMENU hCPUHistoryMenu;
497 hMenu = GetMenu(hMainWnd);
498 hViewMenu = GetSubMenu(hMenu, 2);
499 hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
501 TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
502 CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);