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