perfpage.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*
  2. * ReactOS Task Manager
  3. *
  4. * perfpage.c
  5. *
  6. * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
  7. * Copyright (C) 2008 Vladimir Pankratov
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <windows.h>
  26. #include <commctrl.h>
  27. #include <winnt.h>
  28. #include "taskmgr.h"
  29. #include "perfdata.h"
  30. #include "graphctl.h"
  31. TGraphCtrl PerformancePageCpuUsageHistoryGraph;
  32. TGraphCtrl PerformancePageMemUsageHistoryGraph;
  33. HWND hPerformancePage; /* Performance Property Page */
  34. HWND hPerformancePageCpuUsageGraph; /* CPU Usage Graph */
  35. HWND hPerformancePageMemUsageGraph; /* MEM Usage Graph */
  36. HWND hPerformancePageCpuUsageHistoryGraph; /* CPU Usage History Graph */
  37. HWND hPerformancePageMemUsageHistoryGraph; /* Memory Usage History Graph */
  38. HWND hPerformancePageTotalsFrame; /* Totals Frame */
  39. HWND hPerformancePageCommitChargeFrame; /* Commit Charge Frame */
  40. HWND hPerformancePageKernelMemoryFrame; /* Kernel Memory Frame */
  41. HWND hPerformancePagePhysicalMemoryFrame; /* Physical Memory Frame */
  42. HWND hPerformancePageCpuUsageFrame;
  43. HWND hPerformancePageMemUsageFrame;
  44. HWND hPerformancePageCpuUsageHistoryFrame;
  45. HWND hPerformancePageMemUsageHistoryFrame;
  46. HWND hPerformancePageCommitChargeTotalEdit; /* Commit Charge Total Edit Control */
  47. HWND hPerformancePageCommitChargeLimitEdit; /* Commit Charge Limit Edit Control */
  48. HWND hPerformancePageCommitChargePeakEdit; /* Commit Charge Peak Edit Control */
  49. HWND hPerformancePageKernelMemoryTotalEdit; /* Kernel Memory Total Edit Control */
  50. HWND hPerformancePageKernelMemoryPagedEdit; /* Kernel Memory Paged Edit Control */
  51. HWND hPerformancePageKernelMemoryNonPagedEdit; /* Kernel Memory NonPaged Edit Control */
  52. HWND hPerformancePagePhysicalMemoryTotalEdit; /* Physical Memory Total Edit Control */
  53. HWND hPerformancePagePhysicalMemoryAvailableEdit; /* Physical Memory Available Edit Control */
  54. HWND hPerformancePagePhysicalMemorySystemCacheEdit; /* Physical Memory System Cache Edit Control */
  55. HWND hPerformancePageTotalsHandleCountEdit; /* Total Handles Edit Control */
  56. HWND hPerformancePageTotalsProcessCountEdit; /* Total Processes Edit Control */
  57. HWND hPerformancePageTotalsThreadCountEdit; /* Total Threads Edit Control */
  58. static int nPerformancePageWidth;
  59. static int nPerformancePageHeight;
  60. static HANDLE hPerformancePageEvent = NULL; /* When this event becomes signaled then we refresh the performance page */
  61. static void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
  62. {
  63. RECT rc;
  64. int cx, cy, sx, sy;
  65. GetClientRect(hCntrl, &rc);
  66. MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)));
  67. if (pos) {
  68. cx = rc.left;
  69. cy = rc.top;
  70. sx = rc.right - rc.left;
  71. switch (pos) {
  72. case 1:
  73. break;
  74. case 2:
  75. cy += nYDifference / 2;
  76. break;
  77. case 3:
  78. sx += nXDifference;
  79. break;
  80. case 4:
  81. cy += nYDifference / 2;
  82. sx += nXDifference;
  83. break;
  84. }
  85. sy = rc.bottom - rc.top + nYDifference / 2;
  86. SetWindowPos(hCntrl, NULL, cx, cy, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
  87. } else {
  88. cx = rc.left + nXDifference;
  89. cy = rc.top + nYDifference;
  90. SetWindowPos(hCntrl, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
  91. }
  92. InvalidateRect(hCntrl, NULL, TRUE);
  93. }
  94. static void AdjustControlPosition(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
  95. {
  96. AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0);
  97. }
  98. static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
  99. {
  100. AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
  101. }
  102. void RefreshPerformancePage(void)
  103. {
  104. /* Signal the event so that our refresh thread */
  105. /* will wake up and refresh the performance page */
  106. SetEvent(hPerformancePageEvent);
  107. }
  108. static DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
  109. {
  110. ULONG CommitChargeTotal;
  111. ULONG CommitChargeLimit;
  112. ULONG CommitChargePeak;
  113. ULONG KernelMemoryTotal;
  114. ULONG KernelMemoryPaged;
  115. ULONG KernelMemoryNonPaged;
  116. ULONG PhysicalMemoryTotal;
  117. ULONG PhysicalMemoryAvailable;
  118. ULONG PhysicalMemorySystemCache;
  119. ULONG TotalHandles;
  120. ULONG TotalThreads;
  121. ULONG TotalProcesses;
  122. WCHAR Text[256];
  123. static const WCHAR wszFormatDigit[] = {'%','u',0};
  124. WCHAR wszMemUsage[255];
  125. LoadStringW(hInst, IDS_STATUS_BAR_MEMORY_USAGE, wszMemUsage, ARRAY_SIZE(wszMemUsage));
  126. /* Create the event */
  127. hPerformancePageEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
  128. /* If we couldn't create the event then exit the thread */
  129. if (!hPerformancePageEvent)
  130. return 0;
  131. while (1)
  132. {
  133. DWORD dwWaitVal;
  134. /* Wait on the event */
  135. dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE);
  136. /* If the wait failed then the event object must have been */
  137. /* closed and the task manager is exiting so exit this thread */
  138. if (dwWaitVal == WAIT_FAILED)
  139. return 0;
  140. if (dwWaitVal == WAIT_OBJECT_0)
  141. {
  142. ULONG CpuUsage;
  143. ULONG CpuKernelUsage;
  144. int nBarsUsed1, nBarsUsed2;
  145. DWORD_PTR args[2];
  146. /* Reset our event */
  147. ResetEvent(hPerformancePageEvent);
  148. /*
  149. * Update the commit charge info
  150. */
  151. CommitChargeTotal = PerfDataGetCommitChargeTotalK();
  152. CommitChargeLimit = PerfDataGetCommitChargeLimitK();
  153. CommitChargePeak = PerfDataGetCommitChargePeakK();
  154. wsprintfW(Text, wszFormatDigit, CommitChargeTotal);
  155. SetWindowTextW(hPerformancePageCommitChargeTotalEdit, Text);
  156. wsprintfW(Text, wszFormatDigit, CommitChargeLimit);
  157. SetWindowTextW(hPerformancePageCommitChargeLimitEdit, Text);
  158. wsprintfW(Text, wszFormatDigit, CommitChargePeak);
  159. SetWindowTextW(hPerformancePageCommitChargePeakEdit, Text);
  160. args[0] = CommitChargeTotal;
  161. args[1] = CommitChargeLimit;
  162. FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
  163. wszMemUsage, 0, 0, Text,
  164. ARRAY_SIZE(Text), (__ms_va_list*)args);
  165. SendMessageW(hStatusWnd, SB_SETTEXTW, 2, (LPARAM)Text);
  166. /*
  167. * Update the kernel memory info
  168. */
  169. KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
  170. KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
  171. KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
  172. wsprintfW(Text, wszFormatDigit, KernelMemoryTotal);
  173. SetWindowTextW(hPerformancePageKernelMemoryTotalEdit, Text);
  174. wsprintfW(Text, wszFormatDigit, KernelMemoryPaged);
  175. SetWindowTextW(hPerformancePageKernelMemoryPagedEdit, Text);
  176. wsprintfW(Text, wszFormatDigit, KernelMemoryNonPaged);
  177. SetWindowTextW(hPerformancePageKernelMemoryNonPagedEdit, Text);
  178. /*
  179. * Update the physical memory info
  180. */
  181. PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
  182. PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
  183. PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
  184. wsprintfW(Text, wszFormatDigit, PhysicalMemoryTotal);
  185. SetWindowTextW(hPerformancePagePhysicalMemoryTotalEdit, Text);
  186. wsprintfW(Text, wszFormatDigit, PhysicalMemoryAvailable);
  187. SetWindowTextW(hPerformancePagePhysicalMemoryAvailableEdit, Text);
  188. wsprintfW(Text, wszFormatDigit, PhysicalMemorySystemCache);
  189. SetWindowTextW(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
  190. /*
  191. * Update the totals info
  192. */
  193. TotalHandles = PerfDataGetSystemHandleCount();
  194. TotalThreads = PerfDataGetTotalThreadCount();
  195. TotalProcesses = PerfDataGetProcessCount();
  196. wsprintfW(Text, wszFormatDigit, TotalHandles);
  197. SetWindowTextW(hPerformancePageTotalsHandleCountEdit, Text);
  198. wsprintfW(Text, wszFormatDigit, TotalThreads);
  199. SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text);
  200. wsprintfW(Text, wszFormatDigit, TotalProcesses);
  201. SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text);
  202. /*
  203. * Redraw the graphs
  204. */
  205. InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
  206. InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
  207. /*
  208. * Get the CPU usage
  209. */
  210. CpuUsage = PerfDataGetProcessorUsage();
  211. CpuKernelUsage = PerfDataGetProcessorSystemUsage();
  212. /*
  213. * Get the memory usage
  214. */
  215. CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
  216. CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
  217. nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
  218. PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
  219. PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
  220. nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
  221. GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
  222. GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
  223. /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
  224. InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
  225. InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
  226. }
  227. }
  228. return 0;
  229. }
  230. INT_PTR CALLBACK
  231. PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  232. {
  233. RECT rc;
  234. int nXDifference;
  235. int nYDifference;
  236. switch (message) {
  237. case WM_INITDIALOG:
  238. /* Save the width and height */
  239. GetClientRect(hDlg, &rc);
  240. nPerformancePageWidth = rc.right;
  241. nPerformancePageHeight = rc.bottom;
  242. /* Update window position */
  243. SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
  244. /*
  245. * Get handles to all the controls
  246. */
  247. hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME);
  248. hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME);
  249. hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME);
  250. hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME);
  251. hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME);
  252. hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME);
  253. hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME);
  254. hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME);
  255. hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL);
  256. hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT);
  257. hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK);
  258. hPerformancePageKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL);
  259. hPerformancePageKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED);
  260. hPerformancePageKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED);
  261. hPerformancePagePhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL);
  262. hPerformancePagePhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE);
  263. hPerformancePagePhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE);
  264. hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT);
  265. hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT);
  266. hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT);
  267. hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH);
  268. hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH);
  269. hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
  270. hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
  271. GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc);
  272. /* create the control */
  273. /* PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); */
  274. GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph, hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
  275. /* customize the control */
  276. GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph, 0.0, 100.0, 10);
  277. GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ;
  278. GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(152, 205, 152)) ;
  279. GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(255, 0, 0)) ;
  280. GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(0, 255, 0)) ;
  281. GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc);
  282. GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph, hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
  283. GraphCtrl_SetRange(&PerformancePageMemUsageHistoryGraph, 0.0, 100.0, 10) ;
  284. GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 0, 0)) ;
  285. GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph, RGB(152, 215, 152)) ;
  286. GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ;
  287. /* Start our refresh thread */
  288. #ifdef RUN_PERF_PAGE
  289. CloseHandle( CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL));
  290. #endif
  291. /*
  292. * Subclass graph buttons
  293. */
  294. OldGraphWndProc = (WNDPROC)SetWindowLongPtrW(hPerformancePageCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
  295. SetWindowLongPtrW(hPerformancePageMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
  296. OldGraphCtrlWndProc = (WNDPROC)SetWindowLongPtrW(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
  297. SetWindowLongPtrW(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
  298. return TRUE;
  299. case WM_COMMAND:
  300. break;
  301. case WM_SIZE:
  302. do {
  303. int cx, cy;
  304. if (wParam == SIZE_MINIMIZED)
  305. return 0;
  306. cx = LOWORD(lParam);
  307. cy = HIWORD(lParam);
  308. nXDifference = cx - nPerformancePageWidth;
  309. nYDifference = cy - nPerformancePageHeight;
  310. nPerformancePageWidth = cx;
  311. nPerformancePageHeight = cy;
  312. } while (0);
  313. /* Reposition the performance page's controls */
  314. AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0);
  315. AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0);
  316. AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0);
  317. AdjustFrameSize(hPerformancePagePhysicalMemoryFrame, hDlg, 0, nYDifference, 0);
  318. AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference);
  319. AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference);
  320. AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference);
  321. AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL, hDlg, 0, nYDifference);
  322. AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED, hDlg, 0, nYDifference);
  323. AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED, hDlg, 0, nYDifference);
  324. AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL, hDlg, 0, nYDifference);
  325. AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE, hDlg, 0, nYDifference);
  326. AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE, hDlg, 0, nYDifference);
  327. AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT, hDlg, 0, nYDifference);
  328. AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference);
  329. AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference);
  330. AdjustControlPosition(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference);
  331. AdjustControlPosition(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference);
  332. AdjustControlPosition(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference);
  333. AdjustControlPosition(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference);
  334. AdjustControlPosition(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference);
  335. AdjustControlPosition(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference);
  336. AdjustControlPosition(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference);
  337. AdjustControlPosition(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference);
  338. AdjustControlPosition(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference);
  339. AdjustControlPosition(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference);
  340. AdjustControlPosition(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference);
  341. AdjustControlPosition(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference);
  342. {
  343. static int lastX, lastY;
  344. nXDifference += lastX;
  345. nYDifference += lastY;
  346. lastX = lastY = 0;
  347. if (nXDifference % 2) {
  348. if (nXDifference > 0) {
  349. nXDifference--;
  350. lastX++;
  351. } else {
  352. nXDifference++;
  353. lastX--;
  354. }
  355. }
  356. if (nYDifference % 2) {
  357. if (nYDifference > 0) {
  358. nYDifference--;
  359. lastY++;
  360. } else {
  361. nYDifference++;
  362. lastY--;
  363. }
  364. }
  365. }
  366. AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1);
  367. AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2);
  368. AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3);
  369. AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4);
  370. AdjustFrameSize(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1);
  371. AdjustFrameSize(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2);
  372. AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3);
  373. AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4);
  374. break;
  375. }
  376. return 0;
  377. }
  378. void PerformancePage_OnViewShowKernelTimes(void)
  379. {
  380. HMENU hMenu;
  381. HMENU hViewMenu;
  382. hMenu = GetMenu(hMainWnd);
  383. hViewMenu = GetSubMenu(hMenu, 2);
  384. /* Check or uncheck the show 16-bit tasks menu item */
  385. if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED)
  386. {
  387. CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);
  388. TaskManagerSettings.ShowKernelTimes = FALSE;
  389. }
  390. else
  391. {
  392. CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
  393. TaskManagerSettings.ShowKernelTimes = TRUE;
  394. }
  395. RefreshPerformancePage();
  396. }
  397. void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
  398. {
  399. HMENU hMenu;
  400. HMENU hViewMenu;
  401. HMENU hCPUHistoryMenu;
  402. hMenu = GetMenu(hMainWnd);
  403. hViewMenu = GetSubMenu(hMenu, 2);
  404. hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
  405. TaskManagerSettings.CPUHistory_OneGraphPerCPU = FALSE;
  406. CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND);
  407. }
  408. void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
  409. {
  410. HMENU hMenu;
  411. HMENU hViewMenu;
  412. HMENU hCPUHistoryMenu;
  413. hMenu = GetMenu(hMainWnd);
  414. hViewMenu = GetSubMenu(hMenu, 2);
  415. hCPUHistoryMenu = GetSubMenu(hViewMenu, 3);
  416. TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
  417. CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);
  418. }