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
)
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
)
118 GetClientRect(hCntrl
, &rc
);
119 MapWindowPoints(hCntrl
, hDlg
, (LPPOINT
)(&rc
), (sizeof(RECT
)/sizeof(POINT
)) );
120 // cx = rc.left + nXDifference;
121 // cy = rc.top + nYDifference;
124 sx
= rc
.right
- rc
.left
+ nXDifference
;
125 sy
= rc
.bottom
- rc
.top
+ nYDifference
;
126 // SetWindowPos(hCntrl, NULL, 0, 0, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
127 // SetWindowPos(hCntrl, NULL, cx, cy, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
128 SetWindowPos(hCntrl
, NULL
, cx
, cy
, sx
, sy
, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOZORDER
);
129 InvalidateRect(hCntrl
, NULL
, TRUE
);
132 void AdjustControlPostion(HWND hCntrl
, HWND hDlg
, int nXDifference
, int nYDifference
)
137 GetClientRect(hCntrl
, &rc
);
138 MapWindowPoints(hCntrl
, hDlg
, (LPPOINT
)(&rc
), (sizeof(RECT
)/sizeof(POINT
)));
139 cx
= rc
.left
+ nXDifference
;
140 cy
= rc
.top
+ nYDifference
;
141 SetWindowPos(hCntrl
, NULL
, cx
, cy
, 0, 0, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOSIZE
|SWP_NOZORDER
);
142 InvalidateRect(hCntrl
, NULL
, TRUE
);
145 void AdjustCntrlPos(int ctrl_id
, HWND hDlg
, int nXDifference
, int nYDifference
)
147 AdjustControlPostion(GetDlgItem(hDlg
, ctrl_id
), hDlg
, nXDifference
, nYDifference
);
150 LRESULT CALLBACK
PerformancePageWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
160 // Save the width and height
161 GetClientRect(hDlg
, &rc
);
162 nPerformancePageWidth
= rc
.right
;
163 nPerformancePageHeight
= rc
.bottom
;
165 // Update window position
166 SetWindowPos(hDlg
, NULL
, 15, 30, 0, 0, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOSIZE
|SWP_NOZORDER
);
169 // Get handles to all the controls
171 hPerformancePageTotalsFrame
= GetDlgItem(hDlg
, IDC_TOTALS_FRAME
);
172 hPerformancePageCommitChargeFrame
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_FRAME
);
173 hPerformancePageKernelMemoryFrame
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_FRAME
);
174 hPerformancePagePhysicalMemoryFrame
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_FRAME
);
176 hPerformancePageCpuUsageFrame
= GetDlgItem(hDlg
, IDC_CPU_USAGE_FRAME
);
177 hPerformancePageMemUsageFrame
= GetDlgItem(hDlg
, IDC_MEM_USAGE_FRAME
);
178 hPerformancePageCpuUsageHistoryFrame
= GetDlgItem(hDlg
, IDC_CPU_USAGE_HISTORY_FRAME
);
179 hPerformancePageMemUsageHistoryFrame
= GetDlgItem(hDlg
, IDC_MEMORY_USAGE_HISTORY_FRAME
);
181 hPerformancePageCommitChargeTotalEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_TOTAL
);
182 hPerformancePageCommitChargeLimitEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_LIMIT
);
183 hPerformancePageCommitChargePeakEdit
= GetDlgItem(hDlg
, IDC_COMMIT_CHARGE_PEAK
);
184 hPerformancePageKernelMemoryTotalEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_TOTAL
);
185 hPerformancePageKernelMemoryPagedEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_PAGED
);
186 hPerformancePageKernelMemoryNonPagedEdit
= GetDlgItem(hDlg
, IDC_KERNEL_MEMORY_NONPAGED
);
187 hPerformancePagePhysicalMemoryTotalEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_TOTAL
);
188 hPerformancePagePhysicalMemoryAvailableEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_AVAILABLE
);
189 hPerformancePagePhysicalMemorySystemCacheEdit
= GetDlgItem(hDlg
, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE
);
190 hPerformancePageTotalsHandleCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_HANDLE_COUNT
);
191 hPerformancePageTotalsProcessCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_PROCESS_COUNT
);
192 hPerformancePageTotalsThreadCountEdit
= GetDlgItem(hDlg
, IDC_TOTALS_THREAD_COUNT
);
194 hPerformancePageCommitChargeTotalLabel
= GetDlgItem(hDlg
, IDS_COMMIT_CHARGE_TOTAL
);
195 hPerformancePageCommitChargeLimitLabel
= GetDlgItem(hDlg
, IDS_COMMIT_CHARGE_LIMIT
);
196 hPerformancePageCommitChargePeakLabel
= GetDlgItem(hDlg
, IDS_COMMIT_CHARGE_PEAK
);
197 hPerformancePageKernelMemoryTotalLabel
= GetDlgItem(hDlg
, IDS_KERNEL_MEMORY_TOTAL
);
198 hPerformancePageKernelMemoryPagedLabel
= GetDlgItem(hDlg
, IDS_KERNEL_MEMORY_PAGED
);
199 hPerformancePageKernelMemoryNonPagedLabel
= GetDlgItem(hDlg
, IDS_KERNEL_MEMORY_NONPAGED
);
200 hPerformancePagePhysicalMemoryTotalLabel
= GetDlgItem(hDlg
, IDS_PHYSICAL_MEMORY_TOTAL
);
201 hPerformancePagePhysicalMemoryAvailableLabel
= GetDlgItem(hDlg
, IDS_PHYSICAL_MEMORY_AVAILABLE
);
202 hPerformancePagePhysicalMemorySystemCacheLabel
= GetDlgItem(hDlg
, IDS_PHYSICAL_MEMORY_SYSTEM_CACHE
);
203 hPerformancePageTotalsHandleCountLabel
= GetDlgItem(hDlg
, IDS_TOTALS_HANDLE_COUNT
);
204 hPerformancePageTotalsProcessCountLabel
= GetDlgItem(hDlg
, IDS_TOTALS_PROCESS_COUNT
);
205 hPerformancePageTotalsThreadCountLabel
= GetDlgItem(hDlg
, IDS_TOTALS_THREAD_COUNT
);
207 hPerformancePageCpuUsageGraph
= GetDlgItem(hDlg
, IDC_CPU_USAGE_GRAPH
);
208 hPerformancePageMemUsageGraph
= GetDlgItem(hDlg
, IDC_MEM_USAGE_GRAPH
);
209 hPerformancePageMemUsageHistoryGraph
= GetDlgItem(hDlg
, IDC_MEM_USAGE_HISTORY_GRAPH
);
210 hPerformancePageCpuUsageHistoryGraph
= GetDlgItem(hDlg
, IDC_CPU_USAGE_HISTORY_GRAPH
);
212 GetClientRect(hPerformancePageCpuUsageHistoryGraph
, &rc
);
213 // create the control
214 //PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
215 PerformancePageCpuUsageHistoryGraph
.Create(hPerformancePageCpuUsageHistoryGraph
, hDlg
, IDC_CPU_USAGE_HISTORY_GRAPH
);
216 // customize the control
217 PerformancePageCpuUsageHistoryGraph
.SetRange(0.0, 100.0, 10) ;
218 // PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ;
219 // PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ;
220 // PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ;
221 // PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ;
222 // PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ;
223 PerformancePageCpuUsageHistoryGraph
.SetBackgroundColor(RGB(0, 0, 0)) ;
224 PerformancePageCpuUsageHistoryGraph
.SetGridColor(RGB(152, 205, 152)) ;
225 PerformancePageCpuUsageHistoryGraph
.SetPlotColor(0, RGB(255, 0, 0)) ;
226 PerformancePageCpuUsageHistoryGraph
.SetPlotColor(1, RGB(0, 255, 0)) ;
228 GetClientRect(hPerformancePageMemUsageHistoryGraph
, &rc
);
229 PerformancePageMemUsageHistoryGraph
.Create(hPerformancePageMemUsageHistoryGraph
, hDlg
, IDC_MEM_USAGE_HISTORY_GRAPH
);
230 PerformancePageMemUsageHistoryGraph
.SetRange(0.0, 100.0, 10) ;
231 PerformancePageMemUsageHistoryGraph
.SetBackgroundColor(RGB(0, 0, 0)) ;
232 PerformancePageMemUsageHistoryGraph
.SetGridColor(RGB(152, 215, 152)) ;
233 PerformancePageMemUsageHistoryGraph
.SetPlotColor(0, RGB(255, 255, 0)) ;
235 // Start our refresh thread
237 _beginthread(PerformancePageRefreshThread
, 0, NULL
);
240 // Subclass graph buttons
242 OldGraphWndProc
= SetWindowLong(hPerformancePageCpuUsageGraph
, GWL_WNDPROC
, (LONG
)Graph_WndProc
);
243 SetWindowLong(hPerformancePageMemUsageGraph
, GWL_WNDPROC
, (LONG
)Graph_WndProc
);
244 // SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
246 // OldGraphCtrlWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
247 // SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
248 OldGraphCtrlWndProc
= SetWindowLong(hPerformancePageMemUsageHistoryGraph
, GWL_WNDPROC
, (LONG
)GraphCtrl_WndProc
);
249 SetWindowLong(hPerformancePageCpuUsageHistoryGraph
, GWL_WNDPROC
, (LONG
)GraphCtrl_WndProc
);
258 if (wParam
== SIZE_MINIMIZED
)
263 nXDifference
= cx
- nPerformancePageWidth
;
264 nYDifference
= cy
- nPerformancePageHeight
;
265 nPerformancePageWidth
= cx
;
266 nPerformancePageHeight
= cy
;
267 // SetWindowPos(hPerformancePageMemUsageHistoryGraph, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
268 // SetWindowPos(hPerformancePageCpuUsageHistoryGraph, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
270 // Reposition the performance page's controls
271 AdjustFramePostion(hPerformancePageTotalsFrame
, hDlg
, nXDifference
, nYDifference
);
272 AdjustFramePostion(hPerformancePageCommitChargeFrame
, hDlg
, nXDifference
, nYDifference
);
273 AdjustFramePostion(hPerformancePageKernelMemoryFrame
, hDlg
, nXDifference
, nYDifference
);
274 AdjustFramePostion(hPerformancePagePhysicalMemoryFrame
, hDlg
, nXDifference
, nYDifference
);
275 AdjustFrameSize(hPerformancePageCpuUsageFrame
, hDlg
, nXDifference
, nYDifference
);
276 // AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference);
277 // AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference);
278 // AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference);
280 AdjustControlPostion(hPerformancePageCommitChargeTotalLabel
, hDlg
, nXDifference
, nYDifference
);
281 AdjustControlPostion(hPerformancePageCommitChargeLimitLabel
, hDlg
, nXDifference
, nYDifference
);
282 AdjustControlPostion(hPerformancePageCommitChargePeakLabel
, hDlg
, nXDifference
, nYDifference
);
283 AdjustControlPostion(hPerformancePageKernelMemoryTotalLabel
, hDlg
, nXDifference
, nYDifference
);
284 AdjustControlPostion(hPerformancePageKernelMemoryPagedLabel
, hDlg
, nXDifference
, nYDifference
);
285 AdjustControlPostion(hPerformancePageKernelMemoryNonPagedLabel
, hDlg
, nXDifference
, nYDifference
);
286 AdjustControlPostion(hPerformancePagePhysicalMemoryTotalLabel
, hDlg
, nXDifference
, nYDifference
);
287 AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableLabel
, hDlg
, nXDifference
, nYDifference
);
288 AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheLabel
, hDlg
, nXDifference
, nYDifference
);
289 AdjustControlPostion(hPerformancePageTotalsHandleCountLabel
, hDlg
, nXDifference
, nYDifference
);
290 AdjustControlPostion(hPerformancePageTotalsProcessCountLabel
, hDlg
, nXDifference
, nYDifference
);
291 AdjustControlPostion(hPerformancePageTotalsThreadCountLabel
, hDlg
, nXDifference
, nYDifference
);
293 AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL
, hDlg
, nXDifference
, nYDifference
);
294 AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT
, hDlg
, nXDifference
, nYDifference
);
295 AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK
, hDlg
, nXDifference
, nYDifference
);
296 AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL
, hDlg
, nXDifference
, nYDifference
);
297 AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED
, hDlg
, nXDifference
, nYDifference
);
298 AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED
, hDlg
, nXDifference
, nYDifference
);
299 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL
, hDlg
, nXDifference
, nYDifference
);
300 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE
, hDlg
, nXDifference
, nYDifference
);
301 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE
, hDlg
, nXDifference
, nYDifference
);
302 AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT
, hDlg
, nXDifference
, nYDifference
);
303 AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT
, hDlg
, nXDifference
, nYDifference
);
304 AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT
, hDlg
, nXDifference
, nYDifference
);
307 AdjustControlPostion(hPerformancePageCommitChargeTotalEdit
, hDlg
, nXDifference
, nYDifference
);
308 AdjustControlPostion(hPerformancePageCommitChargeLimitEdit
, hDlg
, nXDifference
, nYDifference
);
309 AdjustControlPostion(hPerformancePageCommitChargePeakEdit
, hDlg
, nXDifference
, nYDifference
);
310 AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit
, hDlg
, nXDifference
, nYDifference
);
311 AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit
, hDlg
, nXDifference
, nYDifference
);
312 AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit
, hDlg
, nXDifference
, nYDifference
);
313 AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit
, hDlg
, nXDifference
, nYDifference
);
314 AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit
, hDlg
, nXDifference
, nYDifference
);
315 AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit
, hDlg
, nXDifference
, nYDifference
);
316 AdjustControlPostion(hPerformancePageTotalsHandleCountEdit
, hDlg
, nXDifference
, nYDifference
);
317 AdjustControlPostion(hPerformancePageTotalsProcessCountEdit
, hDlg
, nXDifference
, nYDifference
);
318 AdjustControlPostion(hPerformancePageTotalsThreadCountEdit
, hDlg
, nXDifference
, nYDifference
);
320 // AdjustControlPostion(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference);
321 // AdjustControlPostion(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference);
322 // AdjustControlPostion(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference);
323 // AdjustControlPostion(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference);
330 void RefreshPerformancePage(void)
332 // Signal the event so that our refresh thread
333 // will wake up and refresh the performance page
334 SetEvent(hPerformancePageEvent
);
337 void PerformancePageRefreshThread(void *lpParameter
)
339 ULONG CommitChargeTotal
;
340 ULONG CommitChargeLimit
;
341 ULONG CommitChargePeak
;
343 ULONG KernelMemoryTotal
;
344 ULONG KernelMemoryPaged
;
345 ULONG KernelMemoryNonPaged
;
347 ULONG PhysicalMemoryTotal
;
348 ULONG PhysicalMemoryAvailable
;
349 ULONG PhysicalMemorySystemCache
;
353 ULONG TotalProcesses
;
358 hPerformancePageEvent
= CreateEvent(NULL
, TRUE
, TRUE
, "Performance Page Event");
360 // If we couldn't create the event then exit the thread
361 if (!hPerformancePageEvent
)
369 dwWaitVal
= WaitForSingleObject(hPerformancePageEvent
, INFINITE
);
371 // If the wait failed then the event object must have been
372 // closed and the task manager is exiting so exit this thread
373 if (dwWaitVal
== WAIT_FAILED
)
376 if (dwWaitVal
== WAIT_OBJECT_0
)
379 ResetEvent(hPerformancePageEvent
);
382 // Update the commit charge info
384 CommitChargeTotal
= PerfDataGetCommitChargeTotalK();
385 CommitChargeLimit
= PerfDataGetCommitChargeLimitK();
386 CommitChargePeak
= PerfDataGetCommitChargePeakK();
387 _ultot(CommitChargeTotal
, Text
, 10);
388 SetWindowText(hPerformancePageCommitChargeTotalEdit
, Text
);
389 _ultot(CommitChargeLimit
, Text
, 10);
390 SetWindowText(hPerformancePageCommitChargeLimitEdit
, Text
);
391 _ultot(CommitChargePeak
, Text
, 10);
392 SetWindowText(hPerformancePageCommitChargePeakEdit
, Text
);
393 wsprintf(Text
, _T("Mem Usage: %dK / %dK"), CommitChargeTotal
, CommitChargeLimit
);
394 SendMessage(hStatusWnd
, SB_SETTEXT
, 2, (LPARAM
)Text
);
397 // Update the kernel memory info
399 KernelMemoryTotal
= PerfDataGetKernelMemoryTotalK();
400 KernelMemoryPaged
= PerfDataGetKernelMemoryPagedK();
401 KernelMemoryNonPaged
= PerfDataGetKernelMemoryNonPagedK();
402 _ultot(KernelMemoryTotal
, Text
, 10);
403 SetWindowText(hPerformancePageKernelMemoryTotalEdit
, Text
);
404 _ultot(KernelMemoryPaged
, Text
, 10);
405 SetWindowText(hPerformancePageKernelMemoryPagedEdit
, Text
);
406 _ultot(KernelMemoryNonPaged
, Text
, 10);
407 SetWindowText(hPerformancePageKernelMemoryNonPagedEdit
, Text
);
410 // Update the physical memory info
412 PhysicalMemoryTotal
= PerfDataGetPhysicalMemoryTotalK();
413 PhysicalMemoryAvailable
= PerfDataGetPhysicalMemoryAvailableK();
414 PhysicalMemorySystemCache
= PerfDataGetPhysicalMemorySystemCacheK();
415 _ultot(PhysicalMemoryTotal
, Text
, 10);
416 SetWindowText(hPerformancePagePhysicalMemoryTotalEdit
, Text
);
417 _ultot(PhysicalMemoryAvailable
, Text
, 10);
418 SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit
, Text
);
419 _ultot(PhysicalMemorySystemCache
, Text
, 10);
420 SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit
, Text
);
423 // Update the totals info
425 TotalHandles
= PerfDataGetSystemHandleCount();
426 TotalThreads
= PerfDataGetTotalThreadCount();
427 TotalProcesses
= PerfDataGetProcessCount();
428 _ultot(TotalHandles
, Text
, 10);
429 SetWindowText(hPerformancePageTotalsHandleCountEdit
, Text
);
430 _ultot(TotalThreads
, Text
, 10);
431 SetWindowText(hPerformancePageTotalsThreadCountEdit
, Text
);
432 _ultot(TotalProcesses
, Text
, 10);
433 SetWindowText(hPerformancePageTotalsProcessCountEdit
, Text
);
438 InvalidateRect(hPerformancePageCpuUsageGraph
, NULL
, FALSE
);
439 InvalidateRect(hPerformancePageMemUsageGraph
, NULL
, FALSE
);
444 ULONG CpuKernelUsage
;
445 ULONGLONG CommitChargeTotal
;
446 ULONGLONG CommitChargeLimit
;
447 ULONG PhysicalMemoryTotal
;
448 ULONG PhysicalMemoryAvailable
;
455 CpuUsage
= PerfDataGetProcessorUsage();
456 CpuKernelUsage
= PerfDataGetProcessorSystemUsage();
457 if (CpuUsage
< 0 ) CpuUsage
= 0;
458 if (CpuUsage
> 100) CpuUsage
= 100;
459 if (CpuKernelUsage
< 0) CpuKernelUsage
= 0;
460 if (CpuKernelUsage
> 100) CpuKernelUsage
= 100;
463 // Get the memory usage
465 CommitChargeTotal
= (ULONGLONG
)PerfDataGetCommitChargeTotalK();
466 CommitChargeLimit
= (ULONGLONG
)PerfDataGetCommitChargeLimitK();
467 nBarsUsed1
= ((CommitChargeTotal
* 100) / CommitChargeLimit
);
469 PhysicalMemoryTotal
= PerfDataGetPhysicalMemoryTotalK();
470 PhysicalMemoryAvailable
= PerfDataGetPhysicalMemoryAvailableK();
471 nBarsUsed2
= ((PhysicalMemoryAvailable
* 100) / PhysicalMemoryTotal
);
474 PerformancePageCpuUsageHistoryGraph
.AppendPoint(CpuUsage
, CpuKernelUsage
);
475 PerformancePageMemUsageHistoryGraph
.AppendPoint(nBarsUsed1
, nBarsUsed2
);
476 //PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
477 InvalidateRect(hPerformancePageMemUsageHistoryGraph
, NULL
, FALSE
);
478 InvalidateRect(hPerformancePageCpuUsageHistoryGraph
, NULL
, FALSE
);
483 void PerformancePage_OnViewShowKernelTimes(void)
488 hMenu
= GetMenu(hMainWnd
);
489 hViewMenu
= GetSubMenu(hMenu
, 2);
491 // Check or uncheck the show 16-bit tasks menu item
492 if (GetMenuState(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
) & MF_CHECKED
)
494 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_UNCHECKED
);
495 TaskManagerSettings
.ShowKernelTimes
= FALSE
;
499 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_CHECKED
);
500 TaskManagerSettings
.ShowKernelTimes
= TRUE
;
503 RefreshPerformancePage();
506 void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
510 HMENU hCPUHistoryMenu
;
512 hMenu
= GetMenu(hMainWnd
);
513 hViewMenu
= GetSubMenu(hMenu
, 2);
514 hCPUHistoryMenu
= GetSubMenu(hViewMenu
, 3);
516 TaskManagerSettings
.CPUHistory_OneGraphPerCPU
= FALSE
;
517 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, MF_BYCOMMAND
);
520 void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
524 HMENU hCPUHistoryMenu
;
526 hMenu
= GetMenu(hMainWnd
);
527 hViewMenu
= GetSubMenu(hMenu
, 2);
528 hCPUHistoryMenu
= GetSubMenu(hViewMenu
, 3);
530 TaskManagerSettings
.CPUHistory_OneGraphPerCPU
= TRUE
;
531 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, MF_BYCOMMAND
);