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
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
38 #include "PerformancePage.h"
42 #include "GraphCtrl.h"
44 TGraphCtrl PerformancePageCpuUsageHistoryGraph
;
45 TGraphCtrl PerformancePageMemUsageHistoryGraph
;
47 HWND hPerformancePage
; // Performance Property Page
49 HWND hPerformancePageCpuUsageGraph
; // CPU Usage Graph
50 HWND hPerformancePageMemUsageGraph
; // MEM Usage Graph
51 HWND hPerformancePageCpuUsageHistoryGraph
; // CPU Usage History Graph
52 HWND hPerformancePageMemUsageHistoryGraph
; // Memory Usage History Graph
54 HWND hPerformancePageTotalsFrame
; // Totals Frame
55 HWND hPerformancePageCommitChargeFrame
; // Commit Charge Frame
56 HWND hPerformancePageKernelMemoryFrame
; // Kernel Memory Frame
57 HWND hPerformancePagePhysicalMemoryFrame
; // Physical Memory Frame
59 HWND hPerformancePageCpuUsageFrame
;
60 HWND hPerformancePageMemUsageFrame
;
61 HWND hPerformancePageCpuUsageHistoryFrame
;
62 HWND hPerformancePageMemUsageHistoryFrame
;
64 HWND hPerformancePageCommitChargeTotalEdit
; // Commit Charge Total Edit Control
65 HWND hPerformancePageCommitChargeLimitEdit
; // Commit Charge Limit Edit Control
66 HWND hPerformancePageCommitChargePeakEdit
; // Commit Charge Peak Edit Control
68 HWND hPerformancePageKernelMemoryTotalEdit
; // Kernel Memory Total Edit Control
69 HWND hPerformancePageKernelMemoryPagedEdit
; // Kernel Memory Paged Edit Control
70 HWND hPerformancePageKernelMemoryNonPagedEdit
; // Kernel Memory NonPaged Edit Control
72 HWND hPerformancePagePhysicalMemoryTotalEdit
; // Physical Memory Total Edit Control
73 HWND hPerformancePagePhysicalMemoryAvailableEdit
; // Physical Memory Available Edit Control
74 HWND hPerformancePagePhysicalMemorySystemCacheEdit
; // Physical Memory System Cache Edit Control
76 HWND hPerformancePageTotalsHandleCountEdit
; // Total Handles Edit Control
77 HWND hPerformancePageTotalsProcessCountEdit
; // Total Processes Edit Control
78 HWND hPerformancePageTotalsThreadCountEdit
; // Total Threads Edit Control
80 HWND hPerformancePageCommitChargeTotalLabel
;
81 HWND hPerformancePageCommitChargeLimitLabel
;
82 HWND hPerformancePageCommitChargePeakLabel
;
83 HWND hPerformancePageKernelMemoryTotalLabel
;
84 HWND hPerformancePageKernelMemoryPagedLabel
;
85 HWND hPerformancePageKernelMemoryNonPagedLabel
;
86 HWND hPerformancePagePhysicalMemoryTotalLabel
;
87 HWND hPerformancePagePhysicalMemoryAvailableLabel
;
88 HWND hPerformancePagePhysicalMemorySystemCacheLabel
;
89 HWND hPerformancePageTotalsHandleCountLabel
;
90 HWND hPerformancePageTotalsProcessCountLabel
;
91 HWND hPerformancePageTotalsThreadCountLabel
;
95 static int nPerformancePageWidth
;
96 static int nPerformancePageHeight
;
98 static HANDLE hPerformancePageEvent
= NULL
; // When this event becomes signaled then we refresh the performance page
100 void PerformancePageRefreshThread(void *lpParameter
);
102 void AdjustFramePostion(HWND hCntrl
, HWND hDlg
, int nXDifference
, int nYDifference
, int)
106 GetClientRect(hCntrl
, &rc
);
107 MapWindowPoints(hCntrl
, hDlg
, (LPPOINT
)(&rc
), (sizeof(RECT
)/sizeof(POINT
)));
108 cx
= rc
.left
+ nXDifference
;
109 cy
= rc
.top
+ nYDifference
;
110 SetWindowPos(hCntrl
, NULL
, cx
, cy
, 0, 0, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOSIZE
|SWP_NOZORDER
);
111 InvalidateRect(hCntrl
, NULL
, TRUE
);
114 void AdjustFrameSize(HWND hCntrl
, HWND hDlg
, int nXDifference
, int nYDifference
, int pos
)
118 GetClientRect(hCntrl
, &rc
);
119 MapWindowPoints(hCntrl
, hDlg
, (LPPOINT
)(&rc
), (sizeof(RECT
)/sizeof(POINT
)));
127 cy
+= nYDifference
/ 2;
130 cx
+= nXDifference
/ 2;
133 cx
+= nXDifference
/ 2;
134 cy
+= nYDifference
/ 2;
137 sx
= rc
.right
- rc
.left
+ nXDifference
/ 2;
138 sy
= rc
.bottom
- rc
.top
+ nYDifference
/ 2;
140 cx
= rc
.left
+ nXDifference
;
141 cy
= rc
.top
+ nYDifference
;
144 SetWindowPos(hCntrl
, NULL
, cx
, cy
, sx
, sy
, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOZORDER
);
145 InvalidateRect(hCntrl
, NULL
, TRUE
);
148 void AdjustControlPostion(HWND hCntrl
, HWND hDlg
, int nXDifference
, int nYDifference
)
153 GetClientRect(hCntrl
, &rc
);
154 MapWindowPoints(hCntrl
, hDlg
, (LPPOINT
)(&rc
), (sizeof(RECT
)/sizeof(POINT
)));
155 cx
= rc
.left
+ nXDifference
;
156 cy
= rc
.top
+ nYDifference
;
157 SetWindowPos(hCntrl
, NULL
, cx
, cy
, 0, 0, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOSIZE
|SWP_NOZORDER
);
158 InvalidateRect(hCntrl
, NULL
, TRUE
);
161 void AdjustCntrlPos(int ctrl_id
, HWND hDlg
, int nXDifference
, int nYDifference
)
163 AdjustControlPostion(GetDlgItem(hDlg
, ctrl_id
), hDlg
, nXDifference
, nYDifference
);
166 LRESULT CALLBACK
PerformancePageWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
176 // Save the width and height
177 GetClientRect(hDlg
, &rc
);
178 nPerformancePageWidth
= rc
.right
;
179 nPerformancePageHeight
= rc
.bottom
;
181 // Update window position
182 SetWindowPos(hDlg
, NULL
, 15, 30, 0, 0, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOSIZE
|SWP_NOZORDER
);
185 // Get handles to all the controls
187 hPerformancePageTotalsFrame
= GetDlgItem(hDlg
, IDC_TOTALS_FRAME
);
188 hPerformancePageCommitChargeFrame
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_FRAME
);
189 hPerformancePageKernelMemoryFrame
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_FRAME
);
190 hPerformancePagePhysicalMemoryFrame
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_FRAME
);
192 hPerformancePageCpuUsageFrame
= GetDlgItem(hDlg
, IDC_CPU_USAGE_FRAME
);
193 hPerformancePageMemUsageFrame
= GetDlgItem(hDlg
, IDC_MEM_USAGE_FRAME
);
194 hPerformancePageCpuUsageHistoryFrame
= GetDlgItem(hDlg
, IDC_CPU_USAGE_HISTORY_FRAME
);
195 hPerformancePageMemUsageHistoryFrame
= GetDlgItem(hDlg
, IDC_MEMORY_USAGE_HISTORY_FRAME
);
197 hPerformancePageCommitChargeTotalEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_TOTAL
);
198 hPerformancePageCommitChargeLimitEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_LIMIT
);
199 hPerformancePageCommitChargePeakEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_PEAK
);
200 hPerformancePageKernelMemoryTotalEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_TOTAL
);
201 hPerformancePageKernelMemoryPagedEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_PAGED
);
202 hPerformancePageKernelMemoryNonPagedEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_NONPAGED
);
203 hPerformancePagePhysicalMemoryTotalEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_TOTAL
);
204 hPerformancePagePhysicalMemoryAvailableEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_AVAILABLE
);
205 hPerformancePagePhysicalMemorySystemCacheEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE
);
206 hPerformancePageTotalsHandleCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_HANDLE_COUNT
);
207 hPerformancePageTotalsProcessCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_PROCESS_COUNT
);
208 hPerformancePageTotalsThreadCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_THREAD_COUNT
);
210 hPerformancePageCommitChargeTotalLabel
= GetDlgItem(hDlg
, IDS_COMMIT_CHARGE_TOTAL
);
211 hPerformancePageCommitChargeLimitLabel
= GetDlgItem(hDlg
, IDS_COMMIT_CHARGE_LIMIT
);
212 hPerformancePageCommitChargePeakLabel
= GetDlgItem(hDlg
, IDS_COMMIT_CHARGE_PEAK
);
213 hPerformancePageKernelMemoryTotalLabel
= GetDlgItem(hDlg
, IDS_KERNEL_MEMORY_TOTAL
);
214 hPerformancePageKernelMemoryPagedLabel
= GetDlgItem(hDlg
, IDS_KERNEL_MEMORY_PAGED
);
215 hPerformancePageKernelMemoryNonPagedLabel
= GetDlgItem(hDlg
, IDS_KERNEL_MEMORY_NONPAGED
);
216 hPerformancePagePhysicalMemoryTotalLabel
= GetDlgItem(hDlg
, IDS_PHYSICAL_MEMORY_TOTAL
);
217 hPerformancePagePhysicalMemoryAvailableLabel
= GetDlgItem(hDlg
, IDS_PHYSICAL_MEMORY_AVAILABLE
);
218 hPerformancePagePhysicalMemorySystemCacheLabel
= GetDlgItem(hDlg
, IDS_PHYSICAL_MEMORY_SYSTEM_CACHE
);
219 hPerformancePageTotalsHandleCountLabel
= GetDlgItem(hDlg
, IDS_TOTALS_HANDLE_COUNT
);
220 hPerformancePageTotalsProcessCountLabel
= GetDlgItem(hDlg
, IDS_TOTALS_PROCESS_COUNT
);
221 hPerformancePageTotalsThreadCountLabel
= GetDlgItem(hDlg
, IDS_TOTALS_THREAD_COUNT
);
223 hPerformancePageCpuUsageGraph
= GetDlgItem(hDlg
, IDC_CPU_USAGE_GRAPH
);
224 hPerformancePageMemUsageGraph
= GetDlgItem(hDlg
, IDC_MEM_USAGE_GRAPH
);
225 hPerformancePageMemUsageHistoryGraph
= GetDlgItem(hDlg
, IDC_MEM_USAGE_HISTORY_GRAPH
);
226 hPerformancePageCpuUsageHistoryGraph
= GetDlgItem(hDlg
, IDC_CPU_USAGE_HISTORY_GRAPH
);
228 GetClientRect(hPerformancePageCpuUsageHistoryGraph
, &rc
);
229 // create the control
230 //PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
231 PerformancePageCpuUsageHistoryGraph
.Create(hPerformancePageCpuUsageHistoryGraph
, hDlg
, IDC_CPU_USAGE_HISTORY_GRAPH
);
232 // customize the control
233 PerformancePageCpuUsageHistoryGraph
.SetRange(0.0, 100.0, 10) ;
234 // PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ;
235 // PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ;
236 // PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ;
237 // PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ;
238 // PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ;
239 PerformancePageCpuUsageHistoryGraph
.SetBackgroundColor(RGB(0, 0, 0)) ;
240 PerformancePageCpuUsageHistoryGraph
.SetGridColor(RGB(152, 205, 152)) ;
241 PerformancePageCpuUsageHistoryGraph
.SetPlotColor(0, RGB(255, 0, 0)) ;
242 PerformancePageCpuUsageHistoryGraph
.SetPlotColor(1, RGB(0, 255, 0)) ;
244 GetClientRect(hPerformancePageMemUsageHistoryGraph
, &rc
);
245 PerformancePageMemUsageHistoryGraph
.Create(hPerformancePageMemUsageHistoryGraph
, hDlg
, IDC_MEM_USAGE_HISTORY_GRAPH
);
246 PerformancePageMemUsageHistoryGraph
.SetRange(0.0, 100.0, 10) ;
247 PerformancePageMemUsageHistoryGraph
.SetBackgroundColor(RGB(0, 0, 0)) ;
248 PerformancePageMemUsageHistoryGraph
.SetGridColor(RGB(152, 215, 152)) ;
249 PerformancePageMemUsageHistoryGraph
.SetPlotColor(0, RGB(255, 255, 0)) ;
251 // Start our refresh thread
253 _beginthread(PerformancePageRefreshThread
, 0, NULL
);
256 // Subclass graph buttons
258 OldGraphWndProc
= SetWindowLong(hPerformancePageCpuUsageGraph
, GWL_WNDPROC
, (LONG
)Graph_WndProc
);
259 SetWindowLong(hPerformancePageMemUsageGraph
, GWL_WNDPROC
, (LONG
)Graph_WndProc
);
260 // SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
262 // OldGraphCtrlWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
263 // SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
264 OldGraphCtrlWndProc
= SetWindowLong(hPerformancePageMemUsageHistoryGraph
, GWL_WNDPROC
, (LONG
)GraphCtrl_WndProc
);
265 SetWindowLong(hPerformancePageCpuUsageHistoryGraph
, GWL_WNDPROC
, (LONG
)GraphCtrl_WndProc
);
274 if (wParam
== SIZE_MINIMIZED
)
279 nXDifference
= cx
- nPerformancePageWidth
;
280 nYDifference
= cy
- nPerformancePageHeight
;
281 nPerformancePageWidth
= cx
;
282 nPerformancePageHeight
= cy
;
283 // SetWindowPos(hPerformancePageMemUsageHistoryGraph, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
284 // SetWindowPos(hPerformancePageCpuUsageHistoryGraph, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
286 // Reposition the performance page's controls
287 AdjustFramePostion(hPerformancePageTotalsFrame
, hDlg
, 0, nYDifference
, 0);
288 AdjustFramePostion(hPerformancePageCommitChargeFrame
, hDlg
, 0, nYDifference
, 0);
289 AdjustFramePostion(hPerformancePageKernelMemoryFrame
, hDlg
, 0, nYDifference
, 0);
290 AdjustFramePostion(hPerformancePagePhysicalMemoryFrame
, hDlg
, 0, nYDifference
, 0);
292 AdjustControlPostion(hPerformancePageCommitChargeTotalLabel
, hDlg
, 0, nYDifference
);
293 AdjustControlPostion(hPerformancePageCommitChargeLimitLabel
, hDlg
, 0, nYDifference
);
294 AdjustControlPostion(hPerformancePageCommitChargePeakLabel
, hDlg
, 0, nYDifference
);
295 AdjustControlPostion(hPerformancePageKernelMemoryTotalLabel
, hDlg
, 0, nYDifference
);
296 AdjustControlPostion(hPerformancePageKernelMemoryPagedLabel
, hDlg
, 0, nYDifference
);
297 AdjustControlPostion(hPerformancePageKernelMemoryNonPagedLabel
, hDlg
, 0, nYDifference
);
298 AdjustControlPostion(hPerformancePagePhysicalMemoryTotalLabel
, hDlg
, 0, nYDifference
);
299 AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableLabel
, hDlg
, 0, nYDifference
);
300 AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheLabel
, hDlg
, 0, nYDifference
);
301 AdjustControlPostion(hPerformancePageTotalsHandleCountLabel
, hDlg
, 0, nYDifference
);
302 AdjustControlPostion(hPerformancePageTotalsProcessCountLabel
, hDlg
, 0, nYDifference
);
303 AdjustControlPostion(hPerformancePageTotalsThreadCountLabel
, hDlg
, 0, nYDifference
);
305 AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL
, hDlg
, 0, nYDifference
);
306 AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT
, hDlg
, 0, nYDifference
);
307 AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK
, hDlg
, 0, nYDifference
);
308 AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL
, hDlg
, 0, nYDifference
);
309 AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED
, hDlg
, 0, nYDifference
);
310 AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED
, hDlg
, 0, nYDifference
);
311 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL
, hDlg
, 0, nYDifference
);
312 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE
, hDlg
, 0, nYDifference
);
313 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE
, hDlg
, 0, nYDifference
);
314 AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT
, hDlg
, 0, nYDifference
);
315 AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT
, hDlg
, 0, nYDifference
);
316 AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT
, hDlg
, 0, nYDifference
);
319 AdjustControlPostion(hPerformancePageCommitChargeTotalEdit
, hDlg
, 0, nYDifference
);
320 AdjustControlPostion(hPerformancePageCommitChargeLimitEdit
, hDlg
, 0, nYDifference
);
321 AdjustControlPostion(hPerformancePageCommitChargePeakEdit
, hDlg
, 0, nYDifference
);
322 AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit
, hDlg
, 0, nYDifference
);
323 AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit
, hDlg
, 0, nYDifference
);
324 AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit
, hDlg
, 0, nYDifference
);
325 AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit
, hDlg
, 0, nYDifference
);
326 AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit
, hDlg
, 0, nYDifference
);
327 AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit
, hDlg
, 0, nYDifference
);
328 AdjustControlPostion(hPerformancePageTotalsHandleCountEdit
, hDlg
, 0, nYDifference
);
329 AdjustControlPostion(hPerformancePageTotalsProcessCountEdit
, hDlg
, 0, nYDifference
);
330 AdjustControlPostion(hPerformancePageTotalsThreadCountEdit
, hDlg
, 0, nYDifference
);
332 static int lastX
, lastY
;
334 nXDifference
+= lastX
;
335 nYDifference
+= lastY
;
337 if (nXDifference
% 2) {
338 if (nXDifference
> 0) {
346 if (nYDifference
% 2) {
347 if (nYDifference
> 0) {
355 AdjustFrameSize(hPerformancePageCpuUsageFrame
, hDlg
, nXDifference
, nYDifference
, 1);
356 AdjustFrameSize(hPerformancePageMemUsageFrame
, hDlg
, nXDifference
, nYDifference
, 2);
357 AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame
, hDlg
, nXDifference
, nYDifference
, 3);
358 AdjustFrameSize(hPerformancePageMemUsageHistoryFrame
, hDlg
, nXDifference
, nYDifference
, 4);
360 AdjustFramePostion(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1);
361 AdjustFramePostion(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2);
362 AdjustFramePostion(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3);
363 AdjustFramePostion(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4);
371 void RefreshPerformancePage(void)
373 // Signal the event so that our refresh thread
374 // will wake up and refresh the performance page
375 SetEvent(hPerformancePageEvent
);
378 void PerformancePageRefreshThread(void *lpParameter
)
380 ULONG CommitChargeTotal
;
381 ULONG CommitChargeLimit
;
382 ULONG CommitChargePeak
;
384 ULONG KernelMemoryTotal
;
385 ULONG KernelMemoryPaged
;
386 ULONG KernelMemoryNonPaged
;
388 ULONG PhysicalMemoryTotal
;
389 ULONG PhysicalMemoryAvailable
;
390 ULONG PhysicalMemorySystemCache
;
394 ULONG TotalProcesses
;
399 hPerformancePageEvent
= CreateEvent(NULL
, TRUE
, TRUE
, "Performance Page Event");
401 // If we couldn't create the event then exit the thread
402 if (!hPerformancePageEvent
)
410 dwWaitVal
= WaitForSingleObject(hPerformancePageEvent
, INFINITE
);
412 // If the wait failed then the event object must have been
413 // closed and the task manager is exiting so exit this thread
414 if (dwWaitVal
== WAIT_FAILED
)
417 if (dwWaitVal
== WAIT_OBJECT_0
)
420 ResetEvent(hPerformancePageEvent
);
423 // Update the commit charge info
425 CommitChargeTotal
= PerfDataGetCommitChargeTotalK();
426 CommitChargeLimit
= PerfDataGetCommitChargeLimitK();
427 CommitChargePeak
= PerfDataGetCommitChargePeakK();
428 _ultot(CommitChargeTotal
, Text
, 10);
429 SetWindowText(hPerformancePageCommitChargeTotalEdit
, Text
);
430 _ultot(CommitChargeLimit
, Text
, 10);
431 SetWindowText(hPerformancePageCommitChargeLimitEdit
, Text
);
432 _ultot(CommitChargePeak
, Text
, 10);
433 SetWindowText(hPerformancePageCommitChargePeakEdit
, Text
);
434 wsprintf(Text
, _T("Mem Usage: %dK / %dK"), CommitChargeTotal
, CommitChargeLimit
);
435 SendMessage(hStatusWnd
, SB_SETTEXT
, 2, (LPARAM
)Text
);
438 // Update the kernel memory info
440 KernelMemoryTotal
= PerfDataGetKernelMemoryTotalK();
441 KernelMemoryPaged
= PerfDataGetKernelMemoryPagedK();
442 KernelMemoryNonPaged
= PerfDataGetKernelMemoryNonPagedK();
443 _ultot(KernelMemoryTotal
, Text
, 10);
444 SetWindowText(hPerformancePageKernelMemoryTotalEdit
, Text
);
445 _ultot(KernelMemoryPaged
, Text
, 10);
446 SetWindowText(hPerformancePageKernelMemoryPagedEdit
, Text
);
447 _ultot(KernelMemoryNonPaged
, Text
, 10);
448 SetWindowText(hPerformancePageKernelMemoryNonPagedEdit
, Text
);
451 // Update the physical memory info
453 PhysicalMemoryTotal
= PerfDataGetPhysicalMemoryTotalK();
454 PhysicalMemoryAvailable
= PerfDataGetPhysicalMemoryAvailableK();
455 PhysicalMemorySystemCache
= PerfDataGetPhysicalMemorySystemCacheK();
456 _ultot(PhysicalMemoryTotal
, Text
, 10);
457 SetWindowText(hPerformancePagePhysicalMemoryTotalEdit
, Text
);
458 _ultot(PhysicalMemoryAvailable
, Text
, 10);
459 SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit
, Text
);
460 _ultot(PhysicalMemorySystemCache
, Text
, 10);
461 SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit
, Text
);
464 // Update the totals info
466 TotalHandles
= PerfDataGetSystemHandleCount();
467 TotalThreads
= PerfDataGetTotalThreadCount();
468 TotalProcesses
= PerfDataGetProcessCount();
469 _ultot(TotalHandles
, Text
, 10);
470 SetWindowText(hPerformancePageTotalsHandleCountEdit
, Text
);
471 _ultot(TotalThreads
, Text
, 10);
472 SetWindowText(hPerformancePageTotalsThreadCountEdit
, Text
);
473 _ultot(TotalProcesses
, Text
, 10);
474 SetWindowText(hPerformancePageTotalsProcessCountEdit
, Text
);
479 InvalidateRect(hPerformancePageCpuUsageGraph
, NULL
, FALSE
);
480 InvalidateRect(hPerformancePageMemUsageGraph
, NULL
, FALSE
);
485 ULONG CpuKernelUsage
;
486 ULONGLONG CommitChargeTotal
;
487 ULONGLONG CommitChargeLimit
;
488 ULONG PhysicalMemoryTotal
;
489 ULONG PhysicalMemoryAvailable
;
496 CpuUsage
= PerfDataGetProcessorUsage();
497 CpuKernelUsage
= PerfDataGetProcessorSystemUsage();
498 if (CpuUsage
< 0 ) CpuUsage
= 0;
499 if (CpuUsage
> 100) CpuUsage
= 100;
500 if (CpuKernelUsage
< 0) CpuKernelUsage
= 0;
501 if (CpuKernelUsage
> 100) CpuKernelUsage
= 100;
504 // Get the memory usage
506 CommitChargeTotal
= (ULONGLONG
)PerfDataGetCommitChargeTotalK();
507 CommitChargeLimit
= (ULONGLONG
)PerfDataGetCommitChargeLimitK();
508 nBarsUsed1
= ((CommitChargeTotal
* 100) / CommitChargeLimit
);
510 PhysicalMemoryTotal
= PerfDataGetPhysicalMemoryTotalK();
511 PhysicalMemoryAvailable
= PerfDataGetPhysicalMemoryAvailableK();
512 nBarsUsed2
= ((PhysicalMemoryAvailable
* 100) / PhysicalMemoryTotal
);
515 PerformancePageCpuUsageHistoryGraph
.AppendPoint(CpuUsage
, CpuKernelUsage
);
516 PerformancePageMemUsageHistoryGraph
.AppendPoint(nBarsUsed1
, nBarsUsed2
);
517 //PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
518 InvalidateRect(hPerformancePageMemUsageHistoryGraph
, NULL
, FALSE
);
519 InvalidateRect(hPerformancePageCpuUsageHistoryGraph
, NULL
, FALSE
);
524 void PerformancePage_OnViewShowKernelTimes(void)
529 hMenu
= GetMenu(hMainWnd
);
530 hViewMenu
= GetSubMenu(hMenu
, 2);
532 // Check or uncheck the show 16-bit tasks menu item
533 if (GetMenuState(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
) & MF_CHECKED
)
535 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_UNCHECKED
);
536 TaskManagerSettings
.ShowKernelTimes
= FALSE
;
540 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_CHECKED
);
541 TaskManagerSettings
.ShowKernelTimes
= TRUE
;
544 RefreshPerformancePage();
547 void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
551 HMENU hCPUHistoryMenu
;
553 hMenu
= GetMenu(hMainWnd
);
554 hViewMenu
= GetSubMenu(hMenu
, 2);
555 hCPUHistoryMenu
= GetSubMenu(hViewMenu
, 3);
557 TaskManagerSettings
.CPUHistory_OneGraphPerCPU
= FALSE
;
558 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, MF_BYCOMMAND
);
561 void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
565 HMENU hCPUHistoryMenu
;
567 hMenu
= GetMenu(hMainWnd
);
568 hViewMenu
= GetSubMenu(hMenu
, 2);
569 hCPUHistoryMenu
= GetSubMenu(hViewMenu
, 3);
571 TaskManagerSettings
.CPUHistory_OneGraphPerCPU
= TRUE
;
572 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, MF_BYCOMMAND
);