6 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program 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
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 extern BOOL bInMenuLoop
; /* Tells us if we are in the menu loop - from taskmgr.c */
28 TGraphCtrl PerformancePageCpuUsageHistoryGraph
;
29 TGraphCtrl PerformancePageMemUsageHistoryGraph
;
31 HWND hPerformancePage
; /* Performance Property Page */
32 HWND hPerformancePageCpuUsageGraph
; /* CPU Usage Graph */
33 HWND hPerformancePageMemUsageGraph
; /* MEM Usage Graph */
34 HWND hPerformancePageCpuUsageHistoryGraph
; /* CPU Usage History Graph */
35 HWND hPerformancePageMemUsageHistoryGraph
; /* Memory Usage History Graph */
36 HWND hPerformancePageTotalsFrame
; /* Totals Frame */
37 HWND hPerformancePageCommitChargeFrame
; /* Commit Charge Frame */
38 HWND hPerformancePageKernelMemoryFrame
; /* Kernel Memory Frame */
39 HWND hPerformancePagePhysicalMemoryFrame
; /* Physical Memory Frame */
40 HWND hPerformancePageCpuUsageFrame
;
41 HWND hPerformancePageMemUsageFrame
;
42 HWND hPerformancePageCpuUsageHistoryFrame
;
43 HWND hPerformancePageMemUsageHistoryFrame
;
44 HWND hPerformancePageCommitChargeTotalEdit
; /* Commit Charge Total Edit Control */
45 HWND hPerformancePageCommitChargeLimitEdit
; /* Commit Charge Limit Edit Control */
46 HWND hPerformancePageCommitChargePeakEdit
; /* Commit Charge Peak Edit Control */
47 HWND hPerformancePageKernelMemoryTotalEdit
; /* Kernel Memory Total Edit Control */
48 HWND hPerformancePageKernelMemoryPagedEdit
; /* Kernel Memory Paged Edit Control */
49 HWND hPerformancePageKernelMemoryNonPagedEdit
; /* Kernel Memory NonPaged Edit Control */
50 HWND hPerformancePagePhysicalMemoryTotalEdit
; /* Physical Memory Total Edit Control */
51 HWND hPerformancePagePhysicalMemoryAvailableEdit
; /* Physical Memory Available Edit Control */
52 HWND hPerformancePagePhysicalMemorySystemCacheEdit
; /* Physical Memory System Cache Edit Control */
53 HWND hPerformancePageTotalsHandleCountEdit
; /* Total Handles Edit Control */
54 HWND hPerformancePageTotalsProcessCountEdit
; /* Total Processes Edit Control */
55 HWND hPerformancePageTotalsThreadCountEdit
; /* Total Threads Edit Control */
58 static HANDLE hPerformanceThread
= NULL
;
59 static DWORD dwPerformanceThread
;
62 static int nPerformancePageWidth
;
63 static int nPerformancePageHeight
;
64 static int lastX
, lastY
;
65 DWORD WINAPI
PerformancePageRefreshThread(void *lpParameter
);
67 void AdjustFrameSize(HWND hCntrl
, HWND hDlg
, int nXDifference
, int nYDifference
, int pos
)
72 GetClientRect(hCntrl
, &rc
);
73 MapWindowPoints(hCntrl
, hDlg
, (LPPOINT
)(PRECT
)(&rc
), sizeof(RECT
)/sizeof(POINT
));
77 sx
= rc
.right
- rc
.left
;
82 cy
+= nYDifference
/ 2;
88 cy
+= nYDifference
/ 2;
92 sy
= rc
.bottom
- rc
.top
+ nYDifference
/ 2;
93 SetWindowPos(hCntrl
, NULL
, cx
, cy
, sx
, sy
, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOZORDER
);
95 cx
= rc
.left
+ nXDifference
;
96 cy
= rc
.top
+ nYDifference
;
97 SetWindowPos(hCntrl
, NULL
, cx
, cy
, 0, 0, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOSIZE
|SWP_NOZORDER
);
99 InvalidateRect(hCntrl
, NULL
, TRUE
);
102 static void AdjustControlPostion(HWND hCntrl
, HWND hDlg
, int nXDifference
, int nYDifference
)
104 AdjustFrameSize(hCntrl
, hDlg
, nXDifference
, nYDifference
, 0);
107 static void AdjustCntrlPos(int ctrl_id
, HWND hDlg
, int nXDifference
, int nYDifference
)
109 AdjustFrameSize(GetDlgItem(hDlg
, ctrl_id
), hDlg
, nXDifference
, nYDifference
, 0);
113 PerformancePageWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
119 /* PAINTSTRUCT ps; */
123 GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph
);
124 GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph
);
126 EndLocalThread(&hPerformanceThread
, dwPerformanceThread
);
132 /* Save the width and height */
133 GetClientRect(hDlg
, &rc
);
134 nPerformancePageWidth
= rc
.right
;
135 nPerformancePageHeight
= rc
.bottom
;
137 /* Update window position */
138 SetWindowPos(hDlg
, NULL
, 15, 30, 0, 0, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOSIZE
|SWP_NOZORDER
);
141 * Get handles to all the controls
143 hPerformancePageTotalsFrame
= GetDlgItem(hDlg
, IDC_TOTALS_FRAME
);
144 hPerformancePageCommitChargeFrame
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_FRAME
);
145 hPerformancePageKernelMemoryFrame
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_FRAME
);
146 hPerformancePagePhysicalMemoryFrame
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_FRAME
);
148 hPerformancePageCpuUsageFrame
= GetDlgItem(hDlg
, IDC_CPU_USAGE_FRAME
);
149 hPerformancePageMemUsageFrame
= GetDlgItem(hDlg
, IDC_MEM_USAGE_FRAME
);
150 hPerformancePageCpuUsageHistoryFrame
= GetDlgItem(hDlg
, IDC_CPU_USAGE_HISTORY_FRAME
);
151 hPerformancePageMemUsageHistoryFrame
= GetDlgItem(hDlg
, IDC_MEMORY_USAGE_HISTORY_FRAME
);
153 hPerformancePageCommitChargeTotalEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_TOTAL
);
154 hPerformancePageCommitChargeLimitEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_LIMIT
);
155 hPerformancePageCommitChargePeakEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_PEAK
);
156 hPerformancePageKernelMemoryTotalEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_TOTAL
);
157 hPerformancePageKernelMemoryPagedEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_PAGED
);
158 hPerformancePageKernelMemoryNonPagedEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_NONPAGED
);
159 hPerformancePagePhysicalMemoryTotalEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_TOTAL
);
160 hPerformancePagePhysicalMemoryAvailableEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_AVAILABLE
);
161 hPerformancePagePhysicalMemorySystemCacheEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE
);
162 hPerformancePageTotalsHandleCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_HANDLE_COUNT
);
163 hPerformancePageTotalsProcessCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_PROCESS_COUNT
);
164 hPerformancePageTotalsThreadCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_THREAD_COUNT
);
166 hPerformancePageCpuUsageGraph
= GetDlgItem(hDlg
, IDC_CPU_USAGE_GRAPH
);
167 hPerformancePageMemUsageGraph
= GetDlgItem(hDlg
, IDC_MEM_USAGE_GRAPH
);
168 hPerformancePageMemUsageHistoryGraph
= GetDlgItem(hDlg
, IDC_MEM_USAGE_HISTORY_GRAPH
);
169 hPerformancePageCpuUsageHistoryGraph
= GetDlgItem(hDlg
, IDC_CPU_USAGE_HISTORY_GRAPH
);
171 GetClientRect(hPerformancePageCpuUsageHistoryGraph
, &rc
);
172 /* create the control */
173 /* PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); */
174 GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph
, hPerformancePageCpuUsageHistoryGraph
, hDlg
, IDC_CPU_USAGE_HISTORY_GRAPH
);
175 /* customize the control */
176 GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph
, 0.0, 100.0, 10);
177 /* PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ; */
178 /* PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ; */
179 /* PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ; */
180 /* PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ; */
181 /* PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */
182 GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph
, RGB(0, 0, 0)) ;
183 GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph
, RGB(0, 128, 64));
185 GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph
, 0, RGB(0, 255, 0)) ;
186 GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph
, 1, RGB(255, 0, 0)) ;
189 GetClientRect(hPerformancePageMemUsageHistoryGraph
, &rc
);
190 GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph
, hPerformancePageMemUsageHistoryGraph
, hDlg
, IDC_MEM_USAGE_HISTORY_GRAPH
);
191 GraphCtrl_SetRange(&PerformancePageMemUsageHistoryGraph
, 0.0, 100.0, 10) ;
192 GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph
, RGB(0, 0, 0)) ;
193 GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph
, RGB(0, 128, 64)) ;
194 GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph
, 0, RGB(255, 255, 0)) ;
195 /* Start our refresh thread */
197 hPerformanceThread
= CreateThread(NULL
, 0, PerformancePageRefreshThread
, NULL
, 0, &dwPerformanceThread
);
201 * Subclass graph buttons
203 OldGraphWndProc
= (WNDPROC
)SetWindowLongPtrW(hPerformancePageCpuUsageGraph
, GWLP_WNDPROC
, (LONG_PTR
)Graph_WndProc
);
204 SetWindowLongPtrW(hPerformancePageMemUsageGraph
, GWLP_WNDPROC
, (LONG_PTR
)Graph_WndProc
);
205 OldGraphCtrlWndProc
= (WNDPROC
)SetWindowLongPtrW(hPerformancePageMemUsageHistoryGraph
, GWLP_WNDPROC
, (LONG_PTR
)GraphCtrl_WndProc
);
206 SetWindowLongPtrW(hPerformancePageCpuUsageHistoryGraph
, GWLP_WNDPROC
, (LONG_PTR
)GraphCtrl_WndProc
);
214 GetClientRect(hDlg
, &rc
);
215 Draw3dRect(hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.top
+ 2, GetSysColor(COLOR_3DSHADOW
), GetSysColor(COLOR_3DHILIGHT
));
216 ReleaseDC(hDlg
, hdc
);
220 hdc
= BeginPaint(hDlg
, &ps
);
221 GetClientRect(hDlg
, &rc
);
222 Draw3dRect(hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.top
+ 2, GetSysColor(COLOR_3DSHADOW
), GetSysColor(COLOR_3DHILIGHT
));
230 if (wParam
== SIZE_MINIMIZED
)
235 nXDifference
= cx
- nPerformancePageWidth
;
236 nYDifference
= cy
- nPerformancePageHeight
;
237 nPerformancePageWidth
= cx
;
238 nPerformancePageHeight
= cy
;
241 /* Reposition the performance page's controls */
242 AdjustFrameSize(hPerformancePageTotalsFrame
, hDlg
, 0, nYDifference
, 0);
243 AdjustFrameSize(hPerformancePageCommitChargeFrame
, hDlg
, 0, nYDifference
, 0);
244 AdjustFrameSize(hPerformancePageKernelMemoryFrame
, hDlg
, 0, nYDifference
, 0);
245 AdjustFrameSize(hPerformancePagePhysicalMemoryFrame
, hDlg
, 0, nYDifference
, 0);
246 AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL
, hDlg
, 0, nYDifference
);
247 AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT
, hDlg
, 0, nYDifference
);
248 AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK
, hDlg
, 0, nYDifference
);
249 AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL
, hDlg
, 0, nYDifference
);
250 AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED
, hDlg
, 0, nYDifference
);
251 AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED
, hDlg
, 0, nYDifference
);
252 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL
, hDlg
, 0, nYDifference
);
253 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE
, hDlg
, 0, nYDifference
);
254 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE
, hDlg
, 0, nYDifference
);
255 AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT
, hDlg
, 0, nYDifference
);
256 AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT
, hDlg
, 0, nYDifference
);
257 AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT
, hDlg
, 0, nYDifference
);
259 AdjustControlPostion(hPerformancePageCommitChargeTotalEdit
, hDlg
, 0, nYDifference
);
260 AdjustControlPostion(hPerformancePageCommitChargeLimitEdit
, hDlg
, 0, nYDifference
);
261 AdjustControlPostion(hPerformancePageCommitChargePeakEdit
, hDlg
, 0, nYDifference
);
262 AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit
, hDlg
, 0, nYDifference
);
263 AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit
, hDlg
, 0, nYDifference
);
264 AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit
, hDlg
, 0, nYDifference
);
265 AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit
, hDlg
, 0, nYDifference
);
266 AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit
, hDlg
, 0, nYDifference
);
267 AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit
, hDlg
, 0, nYDifference
);
268 AdjustControlPostion(hPerformancePageTotalsHandleCountEdit
, hDlg
, 0, nYDifference
);
269 AdjustControlPostion(hPerformancePageTotalsProcessCountEdit
, hDlg
, 0, nYDifference
);
270 AdjustControlPostion(hPerformancePageTotalsThreadCountEdit
, hDlg
, 0, nYDifference
);
272 nXDifference
+= lastX
;
273 nYDifference
+= lastY
;
275 if (nXDifference
% 2) {
276 if (nXDifference
> 0) {
284 if (nYDifference
% 2) {
285 if (nYDifference
> 0) {
293 AdjustFrameSize(hPerformancePageCpuUsageFrame
, hDlg
, nXDifference
, nYDifference
, 1);
294 AdjustFrameSize(hPerformancePageMemUsageFrame
, hDlg
, nXDifference
, nYDifference
, 2);
295 AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame
, hDlg
, nXDifference
, nYDifference
, 3);
296 AdjustFrameSize(hPerformancePageMemUsageHistoryFrame
, hDlg
, nXDifference
, nYDifference
, 4);
297 AdjustFrameSize(hPerformancePageCpuUsageGraph
, hDlg
, nXDifference
, nYDifference
, 1);
298 AdjustFrameSize(hPerformancePageMemUsageGraph
, hDlg
, nXDifference
, nYDifference
, 2);
299 AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph
, hDlg
, nXDifference
, nYDifference
, 3);
300 AdjustFrameSize(hPerformancePageMemUsageHistoryGraph
, hDlg
, nXDifference
, nYDifference
, 4);
306 void RefreshPerformancePage(void)
309 /* Signal the event so that our refresh thread */
310 /* will wake up and refresh the performance page */
311 PostThreadMessage(dwPerformanceThread
, WM_TIMER
, 0, 0);
315 DWORD WINAPI
PerformancePageRefreshThread(void *lpParameter
)
317 ULONGLONG CommitChargeTotal
;
318 ULONGLONG CommitChargeLimit
;
319 ULONGLONG CommitChargePeak
;
322 ULONG CpuKernelUsage
;
324 ULONGLONG KernelMemoryTotal
;
325 ULONGLONG KernelMemoryPaged
;
326 ULONGLONG KernelMemoryNonPaged
;
328 ULONGLONG PhysicalMemoryTotal
;
329 ULONGLONG PhysicalMemoryAvailable
;
330 ULONGLONG PhysicalMemorySystemCache
;
334 ULONG TotalProcesses
;
339 WCHAR szMemUsage
[256], szCpuUsage
[256], szProcesses
[256];
341 LoadStringW(hInst
, IDS_STATUS_CPUUSAGE
, szCpuUsage
, 256);
342 LoadStringW(hInst
, IDS_STATUS_MEMUSAGE
, szMemUsage
, 256);
343 LoadStringW(hInst
, IDS_STATUS_PROCESSES
, szProcesses
, 256);
350 WCHAR szChargeTotalFormat
[256];
351 WCHAR szChargeLimitFormat
[256];
353 /* Wait for an the event or application close */
354 if (GetMessage(&msg
, NULL
, 0, 0) <= 0)
357 if (msg
.message
== WM_TIMER
)
360 * Update the commit charge info
362 CommitChargeTotal
= PerfDataGetCommitChargeTotalK();
363 CommitChargeLimit
= PerfDataGetCommitChargeLimitK();
364 CommitChargePeak
= PerfDataGetCommitChargePeakK();
365 _ultow(CommitChargeTotal
, Text
, 10);
366 SetWindowTextW(hPerformancePageCommitChargeTotalEdit
, Text
);
367 _ultow(CommitChargeLimit
, Text
, 10);
368 SetWindowTextW(hPerformancePageCommitChargeLimitEdit
, Text
);
369 _ultow(CommitChargePeak
, Text
, 10);
370 SetWindowTextW(hPerformancePageCommitChargePeakEdit
, Text
);
372 StrFormatByteSizeW(CommitChargeTotal
* 1024,
374 _countof(szChargeTotalFormat
));
376 StrFormatByteSizeW(CommitChargeLimit
* 1024,
378 _countof(szChargeLimitFormat
));
382 wsprintfW(Text
, szMemUsage
, szChargeTotalFormat
, szChargeLimitFormat
,
383 (CommitChargeLimit
? ((CommitChargeTotal
* 100) / CommitChargeLimit
) : 0));
384 SendMessageW(hStatusWnd
, SB_SETTEXT
, 2, (LPARAM
)Text
);
388 * Update the kernel memory info
390 KernelMemoryTotal
= PerfDataGetKernelMemoryTotalK();
391 KernelMemoryPaged
= PerfDataGetKernelMemoryPagedK();
392 KernelMemoryNonPaged
= PerfDataGetKernelMemoryNonPagedK();
393 _ultow(KernelMemoryTotal
, Text
, 10);
394 SetWindowTextW(hPerformancePageKernelMemoryTotalEdit
, Text
);
395 _ultow(KernelMemoryPaged
, Text
, 10);
396 SetWindowTextW(hPerformancePageKernelMemoryPagedEdit
, Text
);
397 _ultow(KernelMemoryNonPaged
, Text
, 10);
398 SetWindowTextW(hPerformancePageKernelMemoryNonPagedEdit
, Text
);
401 * Update the physical memory info
403 PhysicalMemoryTotal
= PerfDataGetPhysicalMemoryTotalK();
404 PhysicalMemoryAvailable
= PerfDataGetPhysicalMemoryAvailableK();
405 PhysicalMemorySystemCache
= PerfDataGetPhysicalMemorySystemCacheK();
406 _ultow(PhysicalMemoryTotal
, Text
, 10);
407 SetWindowTextW(hPerformancePagePhysicalMemoryTotalEdit
, Text
);
408 _ultow(PhysicalMemoryAvailable
, Text
, 10);
409 SetWindowTextW(hPerformancePagePhysicalMemoryAvailableEdit
, Text
);
410 _ultow(PhysicalMemorySystemCache
, Text
, 10);
411 SetWindowTextW(hPerformancePagePhysicalMemorySystemCacheEdit
, Text
);
414 * Update the totals info
416 TotalHandles
= PerfDataGetSystemHandleCount();
417 TotalThreads
= PerfDataGetTotalThreadCount();
418 TotalProcesses
= PerfDataGetProcessCount();
419 _ultow(TotalHandles
, Text
, 10);
420 SetWindowTextW(hPerformancePageTotalsHandleCountEdit
, Text
);
421 _ultow(TotalThreads
, Text
, 10);
422 SetWindowTextW(hPerformancePageTotalsThreadCountEdit
, Text
);
423 _ultow(TotalProcesses
, Text
, 10);
424 SetWindowTextW(hPerformancePageTotalsProcessCountEdit
, Text
);
427 wsprintfW(Text
, szProcesses
, TotalProcesses
);
428 SendMessageW(hStatusWnd
, SB_SETTEXT
, 0, (LPARAM
)Text
);
434 InvalidateRect(hPerformancePageCpuUsageGraph
, NULL
, FALSE
);
435 InvalidateRect(hPerformancePageMemUsageGraph
, NULL
, FALSE
);
440 CpuUsage
= PerfDataGetProcessorUsage();
441 if (CpuUsage
<= 0 ) CpuUsage
= 0;
442 if (CpuUsage
> 100) CpuUsage
= 100;
446 wsprintfW(Text
, szCpuUsage
, CpuUsage
);
447 SendMessageW(hStatusWnd
, SB_SETTEXT
, 1, (LPARAM
)Text
);
450 if (TaskManagerSettings
.ShowKernelTimes
)
452 CpuKernelUsage
= PerfDataGetProcessorSystemUsage();
453 if (CpuKernelUsage
<= 0) CpuKernelUsage
= 0;
454 if (CpuKernelUsage
> 100) CpuKernelUsage
= 100;
461 * Get the memory usage
463 CommitChargeTotal
= PerfDataGetCommitChargeTotalK();
464 CommitChargeLimit
= PerfDataGetCommitChargeLimitK();
465 nBarsUsed1
= CommitChargeLimit
? ((CommitChargeTotal
* 100) / CommitChargeLimit
) : 0;
467 PhysicalMemoryTotal
= PerfDataGetPhysicalMemoryTotalK();
468 PhysicalMemoryAvailable
= PerfDataGetPhysicalMemoryAvailableK();
469 nBarsUsed2
= PhysicalMemoryTotal
? ((PhysicalMemoryAvailable
* 100) / PhysicalMemoryTotal
) : 0;
471 GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph
, CpuUsage
, CpuKernelUsage
, 0.0, 0.0);
472 GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph
, nBarsUsed1
, nBarsUsed2
, 0.0, 0.0);
473 /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
474 InvalidateRect(hPerformancePageMemUsageHistoryGraph
, NULL
, FALSE
);
475 InvalidateRect(hPerformancePageCpuUsageHistoryGraph
, NULL
, FALSE
);
481 void PerformancePage_OnViewShowKernelTimes(void)
486 hMenu
= GetMenu(hMainWnd
);
487 hViewMenu
= GetSubMenu(hMenu
, 2);
489 /* Check or uncheck the show 16-bit tasks menu item */
490 if (GetMenuState(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
) & MF_CHECKED
)
492 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_UNCHECKED
);
493 TaskManagerSettings
.ShowKernelTimes
= FALSE
;
497 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_CHECKED
);
498 TaskManagerSettings
.ShowKernelTimes
= TRUE
;
501 RefreshPerformancePage();
504 void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
508 HMENU hCPUHistoryMenu
;
510 hMenu
= GetMenu(hMainWnd
);
511 hViewMenu
= GetSubMenu(hMenu
, 2);
512 hCPUHistoryMenu
= GetSubMenu(hViewMenu
, 3);
514 TaskManagerSettings
.CPUHistory_OneGraphPerCPU
= FALSE
;
515 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, MF_BYCOMMAND
);
518 void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
522 HMENU hCPUHistoryMenu
;
524 hMenu
= GetMenu(hMainWnd
);
525 hViewMenu
= GetSubMenu(hMenu
, 2);
526 hCPUHistoryMenu
= GetSubMenu(hViewMenu
, 3);
528 TaskManagerSettings
.CPUHistory_OneGraphPerCPU
= TRUE
;
529 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, MF_BYCOMMAND
);