ReactOS  0.4.12-dev-14-gd0c8636
perfpage.c
Go to the documentation of this file.
1 /*
2  * ReactOS Task Manager
3  *
4  * perfpage.c
5  *
6  * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
7  *
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.
12  *
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.
17  *
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.
21  */
22 
23 #include "precomp.h"
24 #include <shlwapi.h>
25 
26 extern BOOL bInMenuLoop; /* Tells us if we are in the menu loop - from taskmgr.c */
27 
30 
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 */
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 */
56 
57 #ifdef RUN_PERF_PAGE
60 #endif
61 
64 static int lastX, lastY;
66 
67 void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
68 {
69  RECT rc;
70  int cx, cy, sx, sy;
71 
72  GetClientRect(hCntrl, &rc);
73  MapWindowPoints(hCntrl, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT));
74  if (pos) {
75  cx = rc.left;
76  cy = rc.top;
77  sx = rc.right - rc.left;
78  switch (pos) {
79  case 1:
80  break;
81  case 2:
82  cy += nYDifference / 2;
83  break;
84  case 3:
85  sx += nXDifference;
86  break;
87  case 4:
88  cy += nYDifference / 2;
89  sx += nXDifference;
90  break;
91  }
92  sy = rc.bottom - rc.top + nYDifference / 2;
94  } else {
95  cx = rc.left + nXDifference;
96  cy = rc.top + nYDifference;
98  }
99  InvalidateRect(hCntrl, NULL, TRUE);
100 }
101 
102 static void AdjustControlPosition(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
103 {
104  AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0);
105 }
106 
107 static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
108 {
109  AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
110 }
111 
114 {
115  RECT rc;
116  int nXDifference;
117  int nYDifference;
118 /* HDC hdc; */
119 /* PAINTSTRUCT ps; */
120 
121  switch (message) {
122  case WM_DESTROY:
123  GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph);
124  GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph);
125 #ifdef RUN_PERF_PAGE
126  EndLocalThread(&hPerformanceThread, dwPerformanceThread);
127 #endif
128  break;
129 
130  case WM_INITDIALOG:
131 
132  /* Save the width and height */
133  GetClientRect(hDlg, &rc);
136 
137  /* Update window position */
139 
140  /*
141  * Get handles to all the controls
142  */
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);
147 
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);
152 
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);
165 
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);
170 
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));
184 
185  GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(0, 255, 0)) ;
186  GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(255, 0, 0)) ;
187 
188 
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 */
196 #ifdef RUN_PERF_PAGE
198 #endif
199 
200  /*
201  * Subclass graph buttons
202  */
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);
207  return TRUE;
208 
209  case WM_COMMAND:
210  break;
211 #if 0
212  case WM_NCPAINT:
213  hdc = GetDC(hDlg);
214  GetClientRect(hDlg, &rc);
216  ReleaseDC(hDlg, hdc);
217  break;
218 
219  case WM_PAINT:
220  hdc = BeginPaint(hDlg, &ps);
221  GetClientRect(hDlg, &rc);
223  EndPaint(hDlg, &ps);
224  break;
225 #endif
226  case WM_SIZE:
227  do {
228  int cx, cy;
229 
230  if (wParam == SIZE_MINIMIZED)
231  return 0;
232 
233  cx = LOWORD(lParam);
234  cy = HIWORD(lParam);
235  nXDifference = cx - nPerformancePageWidth;
236  nYDifference = cy - nPerformancePageHeight;
237  nPerformancePageWidth = cx;
238  nPerformancePageHeight = cy;
239  } while (0);
240 
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);
258 
259  AdjustControlPosition(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference);
260  AdjustControlPosition(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference);
261  AdjustControlPosition(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference);
262  AdjustControlPosition(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference);
263  AdjustControlPosition(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference);
264  AdjustControlPosition(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference);
265  AdjustControlPosition(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference);
266  AdjustControlPosition(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference);
267  AdjustControlPosition(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference);
268  AdjustControlPosition(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference);
269  AdjustControlPosition(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference);
270  AdjustControlPosition(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference);
271 
272  nXDifference += lastX;
273  nYDifference += lastY;
274  lastX = lastY = 0;
275  if (nXDifference % 2) {
276  if (nXDifference > 0) {
277  nXDifference--;
278  lastX++;
279  } else {
280  nXDifference++;
281  lastX--;
282  }
283  }
284  if (nYDifference % 2) {
285  if (nYDifference > 0) {
286  nYDifference--;
287  lastY++;
288  } else {
289  nYDifference++;
290  lastY--;
291  }
292  }
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);
301  break;
302  }
303  return 0;
304 }
305 
307 {
308 #ifdef RUN_PERF_PAGE
309  /* Signal the event so that our refresh thread */
310  /* will wake up and refresh the performance page */
312 #endif
313 }
314 
316 {
317  ULONGLONG CommitChargeTotal;
318  ULONGLONG CommitChargeLimit;
319  ULONGLONG CommitChargePeak;
320 
321  ULONG CpuUsage;
322  ULONG CpuKernelUsage;
323 
324  ULONGLONG KernelMemoryTotal;
325  ULONGLONG KernelMemoryPaged;
326  ULONGLONG KernelMemoryNonPaged;
327 
328  ULONGLONG PhysicalMemoryTotal;
329  ULONGLONG PhysicalMemoryAvailable;
330  ULONGLONG PhysicalMemorySystemCache;
331 
332  ULONG TotalHandles;
333  ULONG TotalThreads;
334  ULONG TotalProcesses;
335 
336  MSG msg;
337 
338  WCHAR Text[260];
339  WCHAR szMemUsage[256], szCpuUsage[256], szProcesses[256];
340 
341  LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, 256);
342  LoadStringW(hInst, IDS_STATUS_MEMUSAGE, szMemUsage, 256);
343  LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256);
344 
345  while (1)
346  {
347  int nBarsUsed1;
348  int nBarsUsed2;
349 
350  WCHAR szChargeTotalFormat[256];
351  WCHAR szChargeLimitFormat[256];
352 
353  /* Wait for an the event or application close */
354  if (GetMessage(&msg, NULL, 0, 0) <= 0)
355  return 0;
356 
357  if (msg.message == WM_TIMER)
358  {
359  /*
360  * Update the commit charge info
361  */
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);
371 
372  StrFormatByteSizeW(CommitChargeTotal * 1024,
373  szChargeTotalFormat,
374  _countof(szChargeTotalFormat));
375 
376  StrFormatByteSizeW(CommitChargeLimit * 1024,
377  szChargeLimitFormat,
378  _countof(szChargeLimitFormat));
379 
380  if (!bInMenuLoop)
381  {
382  wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
383  (CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));
385  }
386 
387  /*
388  * Update the kernel memory info
389  */
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);
399 
400  /*
401  * Update the physical memory info
402  */
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);
412 
413  /*
414  * Update the totals info
415  */
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);
425  if (!bInMenuLoop)
426  {
427  wsprintfW(Text, szProcesses, TotalProcesses);
429  }
430 
431  /*
432  * Redraw the graphs
433  */
434  InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
435  InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
436 
437  /*
438  * Get the CPU usage
439  */
440  CpuUsage = PerfDataGetProcessorUsage();
441  if (CpuUsage <= 0 ) CpuUsage = 0;
442  if (CpuUsage > 100) CpuUsage = 100;
443 
444  if (!bInMenuLoop)
445  {
446  wsprintfW(Text, szCpuUsage, CpuUsage);
448  }
449 
451  {
452  CpuKernelUsage = PerfDataGetProcessorSystemUsage();
453  if (CpuKernelUsage <= 0) CpuKernelUsage = 0;
454  if (CpuKernelUsage > 100) CpuKernelUsage = 100;
455  }
456  else
457  {
458  CpuKernelUsage = 0;
459  }
460  /*
461  * Get the memory usage
462  */
463  CommitChargeTotal = PerfDataGetCommitChargeTotalK();
464  CommitChargeLimit = PerfDataGetCommitChargeLimitK();
465  nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
466 
467  PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
468  PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
469  nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
470 
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);
476  }
477  }
478  return 0;
479 }
480 
482 {
483  HMENU hMenu;
484  HMENU hViewMenu;
485 
486  hMenu = GetMenu(hMainWnd);
487  hViewMenu = GetSubMenu(hMenu, 2);
488 
489  /* Check or uncheck the show 16-bit tasks menu item */
491  {
494  }
495  else
496  {
497  CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
499  }
500 
502 }
503 
505 {
506  HMENU hMenu;
507  HMENU hViewMenu;
508  HMENU hCPUHistoryMenu;
509 
510  hMenu = GetMenu(hMainWnd);
511  hViewMenu = GetSubMenu(hMenu, 2);
512  hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
513 
516 }
517 
519 {
520  HMENU hMenu;
521  HMENU hViewMenu;
522  HMENU hCPUHistoryMenu;
523 
524  hMenu = GetMenu(hMainWnd);
525  hViewMenu = GetSubMenu(hMenu, 2);
526  hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
527 
530 }
531 
ULONG PerfDataGetPhysicalMemorySystemCacheK(void)
Definition: perfdata.c:1088
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
HWND hStatusWnd
Definition: charmap.c:23
static HANDLE hPerformanceThread
Definition: perfpage.c:58
INT_PTR CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: graph.c:34
void GraphCtrl_SetBackgroundColor(TGraphCtrl *this, COLORREF color)
Definition: graphctl.c:178
#define IDC_PHYSICAL_MEMORY_TOTAL
Definition: resource.h:69
HWND hPerformancePageCpuUsageHistoryFrame
Definition: perfpage.c:42
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2376
#define IDS_STATUS_PROCESSES
Definition: resource.h:256
ULONG PerfDataGetKernelMemoryNonPagedK(void)
Definition: perfdata.c:1037
_CRTIMP wchar_t *__cdecl _ultow(_In_ unsigned long _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
#define COLOR_3DHILIGHT
Definition: winuser.h:927
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
TGraphCtrl PerformancePageMemUsageHistoryGraph
Definition: perfpage.c:29
#define IDC_PHYSICAL_MEMORY_SYSTEM_CACHE
Definition: resource.h:75
HWND hPerformancePageTotalsHandleCountEdit
Definition: perfpage.c:53
HWND hPerformancePageKernelMemoryPagedEdit
Definition: perfpage.c:48
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDS_TOTALS_PROCESS_COUNT
Definition: resource.h:126
static int lastX
Definition: perfpage.c:64
HWND hPerformancePageMemUsageGraph
Definition: perfpage.c:33
#define IDC_MEM_USAGE_FRAME
Definition: resource.h:105
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define IDC_CPU_USAGE_FRAME
Definition: resource.h:102
#define IDC_KERNEL_MEMORY_NONPAGED
Definition: resource.h:84
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
Definition: taskmgr.c:549
#define IDC_COMMIT_CHARGE_TOTAL
Definition: resource.h:59
HDC WINAPI GetDC(_In_opt_ HWND)
static DWORD dwPerformanceThread
Definition: perfpage.c:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hPerformancePageCommitChargeFrame
Definition: perfpage.c:37
HWND hPerformancePageMemUsageHistoryGraph
Definition: perfpage.c:35
WNDPROC OldGraphWndProc
Definition: graph.c:27
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
#define _countof(array)
Definition: fontsub.cpp:30
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hPerformancePageMemUsageHistoryFrame
Definition: perfpage.c:43
UINT WINAPI GetMenuState(_In_ HMENU, _In_ UINT, _In_ UINT)
#define CALLBACK
Definition: compat.h:27
LONG top
Definition: windef.h:297
HWND hPerformancePageCommitChargePeakEdit
Definition: perfpage.c:46
ULONG PerfDataGetCommitChargePeakK(void)
Definition: perfdata.c:980
void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
Definition: perfpage.c:518
#define IDC_COMMIT_CHARGE_PEAK
Definition: resource.h:66
HWND hPerformancePageKernelMemoryNonPagedEdit
Definition: perfpage.c:49
#define IDC_PHYSICAL_MEMORY_FRAME
Definition: resource.h:96
ULONG PerfDataGetCommitChargeLimitK(void)
Definition: perfdata.c:963
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
ULONG PerfDataGetTotalThreadCount(void)
Definition: perfdata.c:1116
static int nPerformancePageWidth
Definition: perfpage.c:62
#define IDC_MEMORY_USAGE_HISTORY_FRAME
Definition: resource.h:111
LONG left
Definition: windef.h:296
#define SWP_NOZORDER
Definition: winuser.h:1232
ULONG PerfDataGetProcessorSystemUsage(void)
Definition: perfdata.c:490
#define IDC_KERNEL_MEMORY_PAGED
Definition: resource.h:81
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
int32_t INT_PTR
Definition: typedefs.h:62
DWORD EndLocalThread(HANDLE *hThread, DWORD dwThread)
Definition: taskmgr.c:1178
TGraphCtrl PerformancePageCpuUsageHistoryGraph
Definition: perfpage.c:28
#define IDS_PHYSICAL_MEMORY_TOTAL
Definition: resource.h:130
LONG right
Definition: windef.h:298
HWND hPerformancePage
Definition: perfpage.c:31
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
INT_PTR CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: graphctl.c:543
void GraphCtrl_Dispose(TGraphCtrl *this)
Definition: graphctl.c:104
DWORD WINAPI GetSysColor(_In_ int)
WPARAM wParam
Definition: combotst.c:138
#define COLOR_3DSHADOW
Definition: winuser.h:921
UINT_PTR WPARAM
Definition: windef.h:207
ULONG PerfDataGetSystemHandleCount(void)
Definition: perfdata.c:1103
#define IDC_PHYSICAL_MEMORY_AVAILABLE
Definition: resource.h:72
#define WM_NCPAINT
Definition: winuser.h:1669
#define IDS_PHYSICAL_MEMORY_AVAILABLE
Definition: resource.h:131
ULONG PerfDataGetPhysicalMemoryAvailableK(void)
Definition: perfdata.c:1071
#define IDC_COMMIT_CHARGE_LIMIT
Definition: resource.h:62
static void AdjustControlPosition(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
Definition: perfpage.c:102
#define ID_VIEW_CPUHISTORY_ONEGRAPHALL
Definition: resource.h:162
LONG_PTR LPARAM
Definition: windef.h:208
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define IDS_COMMIT_CHARGE_LIMIT
Definition: resource.h:128
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
ULONG PerfDataGetKernelMemoryPagedK(void)
Definition: perfdata.c:1020
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
HDC hdc
Definition: msvc.h:53
#define ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
Definition: resource.h:163
static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
Definition: perfpage.c:107
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
#define IDC_COMMIT_CHARGE_FRAME
Definition: resource.h:90
smooth NULL
Definition: ftsmooth.c:416
#define IDC_CPU_USAGE_HISTORY_FRAME
Definition: resource.h:108
HWND hPerformancePagePhysicalMemorySystemCacheEdit
Definition: perfpage.c:52
HWND hPerformancePagePhysicalMemoryFrame
Definition: perfpage.c:39
ULONG PerfDataGetProcessCount(void)
Definition: perfdata.c:472
#define WM_DESTROY
Definition: winuser.h:1591
WNDPROC OldGraphCtrlWndProc
Definition: graphctl.c:27
#define MF_CHECKED
Definition: winuser.h:132
unsigned int BOOL
Definition: ntddk_ex.h:94
void GraphCtrl_Create(TGraphCtrl *this, HWND hWnd, HWND hParentWnd, UINT nID)
Definition: graphctl.c:123
#define IDS_COMMIT_CHARGE_PEAK
Definition: resource.h:129
void GraphCtrl_SetRange(TGraphCtrl *this, double dLower, double dUpper, int nDecimalPlaces)
Definition: graphctl.c:134
static int nPerformancePageHeight
Definition: perfpage.c:63
HWND hPerformancePageCommitChargeLimitEdit
Definition: perfpage.c:45
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_SIZE
Definition: winuser.h:1593
void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
Definition: perfpage.c:67
HWND hPerformancePageKernelMemoryFrame
Definition: perfpage.c:38
#define SWP_NOACTIVATE
Definition: winuser.h:1227
uint64_t ULONGLONG
Definition: typedefs.h:65
void GraphCtrl_SetPlotColor(TGraphCtrl *this, int plot, COLORREF color)
Definition: graphctl.c:169
#define WM_TIMER
Definition: winuser.h:1718
void RefreshPerformancePage(void)
Definition: perfpage.c:306
HWND hPerformancePageKernelMemoryTotalEdit
Definition: perfpage.c:47
#define PostThreadMessage
Definition: winuser.h:5699
#define RGB(r, g, b)
Definition: wingdi.h:2917
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define ID_VIEW_SHOWKERNELTIMES
Definition: resource.h:161
#define IDS_STATUS_CPUUSAGE
Definition: resource.h:255
unsigned long DWORD
Definition: ntddk_ex.h:95
static int lastY
Definition: perfpage.c:64
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define IDS_PHYSICAL_MEMORY_SYSTEM_CACHE
Definition: resource.h:132
#define SIZE_MINIMIZED
Definition: winuser.h:2460
HWND hPerformancePageTotalsThreadCountEdit
Definition: perfpage.c:55
#define WM_PAINT
Definition: winuser.h:1602
#define IDS_STATUS_MEMUSAGE
Definition: resource.h:254
HWND hPerformancePageCpuUsageFrame
Definition: perfpage.c:40
HWND hMainWnd
Definition: magnifier.c:33
#define IDS_KERNEL_MEMORY_NONPAGED
Definition: resource.h:135
void GraphCtrl_SetGridColor(TGraphCtrl *this, COLORREF color)
Definition: graphctl.c:162
#define IDC_TOTALS_PROCESS_COUNT
Definition: resource.h:56
#define SB_SETTEXT
Definition: commctrl.h:1919
LPVOID lpParameter
Definition: kernel32.h:232
double GraphCtrl_AppendPoint(TGraphCtrl *this, double dNewPoint0, double dNewPoint1, double dNewPoint2, double dNewPoint3)
Definition: graphctl.c:357
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
void PerformancePage_OnViewShowKernelTimes(void)
Definition: perfpage.c:481
#define WM_COMMAND
Definition: winuser.h:1716
#define IDC_KERNEL_MEMORY_FRAME
Definition: resource.h:93
#define IDS_TOTALS_THREAD_COUNT
Definition: resource.h:125
INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: perfpage.c:113
HWND hPerformancePageCpuUsageGraph
Definition: perfpage.c:32
#define MF_UNCHECKED
Definition: winuser.h:204
#define IDC_TOTALS_HANDLE_COUNT
Definition: resource.h:48
void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
Definition: perfpage.c:504
#define WINAPI
Definition: msvc.h:20
#define GWLP_WNDPROC
Definition: treelist.c:66
#define IDC_CPU_USAGE_HISTORY_GRAPH
Definition: resource.h:121
ULONG PerfDataGetKernelMemoryTotalK(void)
Definition: perfdata.c:997
HWND hPerformancePageCommitChargeTotalEdit
Definition: perfpage.c:44
#define SWP_NOSIZE
Definition: winuser.h:1230
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
HWND hPerformancePageCpuUsageHistoryGraph
Definition: perfpage.c:34
HWND hPerformancePageTotalsProcessCountEdit
Definition: perfpage.c:54
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND hPerformancePagePhysicalMemoryTotalEdit
Definition: perfpage.c:50
#define IDC_TOTALS_THREAD_COUNT
Definition: resource.h:53
HINSTANCE hInst
Definition: dxdiag.c:13
#define IDC_CPU_USAGE_GRAPH
Definition: resource.h:114
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
HWND hPerformancePageMemUsageFrame
Definition: perfpage.c:41
#define GetMessage
Definition: winuser.h:5656
ULONG PerfDataGetCommitChargeTotalK(void)
Definition: perfdata.c:946
ULONG PerfDataGetPhysicalMemoryTotalK(void)
Definition: perfdata.c:1054
HWND hPerformancePageTotalsFrame
Definition: perfpage.c:36
#define IDC_MEM_USAGE_GRAPH
Definition: resource.h:118
#define msg(x)
Definition: auth_time.c:54
_Out_opt_ int * cx
Definition: commctrl.h:570
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
#define IDS_COMMIT_CHARGE_TOTAL
Definition: resource.h:127
#define IDC_MEM_USAGE_HISTORY_GRAPH
Definition: resource.h:120
LONG bottom
Definition: windef.h:299
ULONG PerfDataGetProcessorUsage(void)
Definition: perfdata.c:481
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SetWindowLongPtrW
Definition: winuser.h:5215
HWND hPerformancePagePhysicalMemoryAvailableEdit
Definition: perfpage.c:51
BOOL bInMenuLoop
Definition: taskmgr.c:49
DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
Definition: perfpage.c:315
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
BOOL CPUHistory_OneGraphPerCPU
Definition: taskmgr.h:87
#define LOWORD(l)
Definition: pedump.c:82
#define IDC_KERNEL_MEMORY_TOTAL
Definition: resource.h:78
#define IDS_KERNEL_MEMORY_PAGED
Definition: resource.h:134
#define IDC_TOTALS_FRAME
Definition: resource.h:87
char * Text
Definition: combotst.c:136
#define IDS_KERNEL_MEMORY_TOTAL
Definition: resource.h:133
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234
#define IDS_TOTALS_HANDLE_COUNT
Definition: resource.h:124