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