column.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /*
  2. * ReactOS Task Manager
  3. *
  4. * column.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 "taskmgr.h"
  28. #include "column.h"
  29. UINT ColumnDataHints[25];
  30. /* Column Headers; Begin */
  31. static WCHAR wszImageName[255];
  32. static WCHAR wszPID[255];
  33. static WCHAR wszUserName[255];
  34. static WCHAR wszSessionID[255];
  35. static WCHAR wszCPU[255];
  36. static WCHAR wszCPUTime[255];
  37. static WCHAR wszMemUsage[255];
  38. static WCHAR wszPeakMemUsage[255];
  39. static WCHAR wszMemDelta[255];
  40. static WCHAR wszPageFaults[255];
  41. static WCHAR wszPFDelta[255];
  42. static WCHAR wszVMSize[255];
  43. static WCHAR wszPagedPool[255];
  44. static WCHAR wszNPPool[255];
  45. static WCHAR wszBasePri[255];
  46. static WCHAR wszHandles[255];
  47. static WCHAR wszThreads[255];
  48. static WCHAR wszUSERObjects[255];
  49. static WCHAR wszGDIObjects[255];
  50. static WCHAR wszIOReads[255];
  51. static WCHAR wszIOWrites[255];
  52. static WCHAR wszIOOther[255];
  53. static WCHAR wszIOReadBytes[255];
  54. static WCHAR wszIOWriteBytes[255];
  55. static WCHAR wszIOOtherBytes[255];
  56. /* Column Headers; End */
  57. static void load_column_headers(void)
  58. {
  59. LoadStringW(hInst, IDS_IMAGENAME, wszImageName, ARRAY_SIZE(wszImageName));
  60. LoadStringW(hInst, IDS_PID, wszPID, ARRAY_SIZE(wszPID));
  61. LoadStringW(hInst, IDS_USERNAME, wszUserName, ARRAY_SIZE(wszUserName));
  62. LoadStringW(hInst, IDS_SESSIONID, wszSessionID, ARRAY_SIZE(wszSessionID));
  63. LoadStringW(hInst, IDS_CPUUSAGE, wszCPU, ARRAY_SIZE(wszCPU));
  64. LoadStringW(hInst, IDS_CPUTIME, wszCPUTime, ARRAY_SIZE(wszCPUTime));
  65. LoadStringW(hInst, IDS_MEMORYUSAGE, wszMemUsage, ARRAY_SIZE(wszMemUsage));
  66. LoadStringW(hInst, IDS_PEAKMEMORYUSAGE, wszPeakMemUsage, ARRAY_SIZE(wszPeakMemUsage));
  67. LoadStringW(hInst, IDS_MEMORYUSAGEDELTA, wszMemDelta, ARRAY_SIZE(wszMemDelta));
  68. LoadStringW(hInst, IDS_PAGEFAULTS, wszPageFaults, ARRAY_SIZE(wszPageFaults));
  69. LoadStringW(hInst, IDS_PAGEFAULTSDELTA, wszPFDelta, ARRAY_SIZE(wszPFDelta));
  70. LoadStringW(hInst, IDS_VIRTUALMEMORYSIZE, wszVMSize, ARRAY_SIZE(wszVMSize));
  71. LoadStringW(hInst, IDS_PAGEDPOOL, wszPagedPool, ARRAY_SIZE(wszPagedPool));
  72. LoadStringW(hInst, IDS_NONPAGEDPOOL, wszNPPool, ARRAY_SIZE(wszNPPool));
  73. LoadStringW(hInst, IDS_BASEPRIORITY, wszBasePri, ARRAY_SIZE(wszBasePri));
  74. LoadStringW(hInst, IDS_HANDLECOUNT, wszHandles, ARRAY_SIZE(wszHandles));
  75. LoadStringW(hInst, IDS_THREADCOUNT, wszThreads, ARRAY_SIZE(wszThreads));
  76. LoadStringW(hInst, IDS_USEROBJECTS, wszUSERObjects, ARRAY_SIZE(wszUSERObjects));
  77. LoadStringW(hInst, IDS_GDIOBJECTS, wszGDIObjects, ARRAY_SIZE(wszGDIObjects));
  78. LoadStringW(hInst, IDS_IOREADS, wszIOReads, ARRAY_SIZE(wszIOReads));
  79. LoadStringW(hInst, IDS_IOWRITES, wszIOWrites, ARRAY_SIZE(wszIOWrites));
  80. LoadStringW(hInst, IDS_IOOTHER, wszIOOther, ARRAY_SIZE(wszIOOther));
  81. LoadStringW(hInst, IDS_IOREADBYTES, wszIOReadBytes, ARRAY_SIZE(wszIOReadBytes));
  82. LoadStringW(hInst, IDS_IOWRITEBYTES, wszIOWriteBytes, ARRAY_SIZE(wszIOWriteBytes));
  83. LoadStringW(hInst, IDS_IOOTHERBYTES, wszIOOtherBytes, ARRAY_SIZE(wszIOOtherBytes));
  84. }
  85. static int InsertColumn(int nCol, LPCWSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
  86. {
  87. LVCOLUMNW column;
  88. column.mask = LVCF_TEXT|LVCF_FMT;
  89. column.pszText = (LPWSTR)lpszColumnHeading;
  90. column.fmt = nFormat;
  91. if (nWidth != -1)
  92. {
  93. column.mask |= LVCF_WIDTH;
  94. column.cx = nWidth;
  95. }
  96. if (nSubItem != -1)
  97. {
  98. column.mask |= LVCF_SUBITEM;
  99. column.iSubItem = nSubItem;
  100. }
  101. return ListView_InsertColumnW(hProcessPageListCtrl, nCol, &column);
  102. }
  103. void AddColumns(void)
  104. {
  105. int size;
  106. load_column_headers();
  107. if (TaskManagerSettings.Column_ImageName)
  108. InsertColumn(0, wszImageName, LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[0], -1);
  109. if (TaskManagerSettings.Column_PID)
  110. InsertColumn(1, wszPID, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[1], -1);
  111. if (TaskManagerSettings.Column_UserName)
  112. InsertColumn(2, wszUserName, LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[2], -1);
  113. if (TaskManagerSettings.Column_SessionID)
  114. InsertColumn(3, wszSessionID, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[3], -1);
  115. if (TaskManagerSettings.Column_CPUUsage)
  116. InsertColumn(4, wszCPU, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[4], -1);
  117. if (TaskManagerSettings.Column_CPUTime)
  118. InsertColumn(5, wszCPUTime, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[5], -1);
  119. if (TaskManagerSettings.Column_MemoryUsage)
  120. InsertColumn(6, wszMemUsage, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[6], -1);
  121. if (TaskManagerSettings.Column_PeakMemoryUsage)
  122. InsertColumn(7, wszPeakMemUsage, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[7], -1);
  123. if (TaskManagerSettings.Column_MemoryUsageDelta)
  124. InsertColumn(8, wszMemDelta, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[8], -1);
  125. if (TaskManagerSettings.Column_PageFaults)
  126. InsertColumn(9, wszPageFaults, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[9], -1);
  127. if (TaskManagerSettings.Column_PageFaultsDelta)
  128. InsertColumn(10, wszPFDelta, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[10], -1);
  129. if (TaskManagerSettings.Column_VirtualMemorySize)
  130. InsertColumn(11, wszVMSize, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[11], -1);
  131. if (TaskManagerSettings.Column_PagedPool)
  132. InsertColumn(12, wszPagedPool, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[12], -1);
  133. if (TaskManagerSettings.Column_NonPagedPool)
  134. InsertColumn(13, wszNPPool, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[13], -1);
  135. if (TaskManagerSettings.Column_BasePriority)
  136. InsertColumn(14, wszBasePri, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[14], -1);
  137. if (TaskManagerSettings.Column_HandleCount)
  138. InsertColumn(15, wszHandles, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[15], -1);
  139. if (TaskManagerSettings.Column_ThreadCount)
  140. InsertColumn(16, wszThreads, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[16], -1);
  141. if (TaskManagerSettings.Column_USERObjects)
  142. InsertColumn(17, wszUSERObjects, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[17], -1);
  143. if (TaskManagerSettings.Column_GDIObjects)
  144. InsertColumn(18, wszGDIObjects, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[18], -1);
  145. if (TaskManagerSettings.Column_IOReads)
  146. InsertColumn(19, wszIOReads, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[19], -1);
  147. if (TaskManagerSettings.Column_IOWrites)
  148. InsertColumn(20, wszIOWrites, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[20], -1);
  149. if (TaskManagerSettings.Column_IOOther)
  150. InsertColumn(21, wszIOOther, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[21], -1);
  151. if (TaskManagerSettings.Column_IOReadBytes)
  152. InsertColumn(22, wszIOReadBytes, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[22], -1);
  153. if (TaskManagerSettings.Column_IOWriteBytes)
  154. InsertColumn(23, wszIOWriteBytes, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[23], -1);
  155. if (TaskManagerSettings.Column_IOOtherBytes)
  156. InsertColumn(24, wszIOOtherBytes, LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[24], -1);
  157. size = SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
  158. SendMessageW(hProcessPageListCtrl, LVM_SETCOLUMNORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
  159. UpdateColumnDataHints();
  160. }
  161. static INT_PTR CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  162. {
  163. switch (message)
  164. {
  165. case WM_INITDIALOG:
  166. if (TaskManagerSettings.Column_ImageName)
  167. SendMessageW(GetDlgItem(hDlg, IDC_IMAGENAME), BM_SETCHECK, BST_CHECKED, 0);
  168. if (TaskManagerSettings.Column_PID)
  169. SendMessageW(GetDlgItem(hDlg, IDC_PID), BM_SETCHECK, BST_CHECKED, 0);
  170. if (TaskManagerSettings.Column_UserName)
  171. SendMessageW(GetDlgItem(hDlg, IDC_USERNAME), BM_SETCHECK, BST_CHECKED, 0);
  172. if (TaskManagerSettings.Column_SessionID)
  173. SendMessageW(GetDlgItem(hDlg, IDC_SESSIONID), BM_SETCHECK, BST_CHECKED, 0);
  174. if (TaskManagerSettings.Column_CPUUsage)
  175. SendMessageW(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_SETCHECK, BST_CHECKED, 0);
  176. if (TaskManagerSettings.Column_CPUTime)
  177. SendMessageW(GetDlgItem(hDlg, IDC_CPUTIME), BM_SETCHECK, BST_CHECKED, 0);
  178. if (TaskManagerSettings.Column_MemoryUsage)
  179. SendMessageW(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
  180. if (TaskManagerSettings.Column_PeakMemoryUsage)
  181. SendMessageW(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
  182. if (TaskManagerSettings.Column_MemoryUsageDelta)
  183. SendMessageW(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_SETCHECK, BST_CHECKED, 0);
  184. if (TaskManagerSettings.Column_PageFaults)
  185. SendMessageW(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_SETCHECK, BST_CHECKED, 0);
  186. if (TaskManagerSettings.Column_PageFaultsDelta)
  187. SendMessageW(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_SETCHECK, BST_CHECKED, 0);
  188. if (TaskManagerSettings.Column_VirtualMemorySize)
  189. SendMessageW(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_SETCHECK, BST_CHECKED, 0);
  190. if (TaskManagerSettings.Column_PagedPool)
  191. SendMessageW(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
  192. if (TaskManagerSettings.Column_NonPagedPool)
  193. SendMessageW(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
  194. if (TaskManagerSettings.Column_BasePriority)
  195. SendMessageW(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_SETCHECK, BST_CHECKED, 0);
  196. if (TaskManagerSettings.Column_HandleCount)
  197. SendMessageW(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_SETCHECK, BST_CHECKED, 0);
  198. if (TaskManagerSettings.Column_ThreadCount)
  199. SendMessageW(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_SETCHECK, BST_CHECKED, 0);
  200. if (TaskManagerSettings.Column_USERObjects)
  201. SendMessageW(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_SETCHECK, BST_CHECKED, 0);
  202. if (TaskManagerSettings.Column_GDIObjects)
  203. SendMessageW(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_SETCHECK, BST_CHECKED, 0);
  204. if (TaskManagerSettings.Column_IOReads)
  205. SendMessageW(GetDlgItem(hDlg, IDC_IOREADS), BM_SETCHECK, BST_CHECKED, 0);
  206. if (TaskManagerSettings.Column_IOWrites)
  207. SendMessageW(GetDlgItem(hDlg, IDC_IOWRITES), BM_SETCHECK, BST_CHECKED, 0);
  208. if (TaskManagerSettings.Column_IOOther)
  209. SendMessageW(GetDlgItem(hDlg, IDC_IOOTHER), BM_SETCHECK, BST_CHECKED, 0);
  210. if (TaskManagerSettings.Column_IOReadBytes)
  211. SendMessageW(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_SETCHECK, BST_CHECKED, 0);
  212. if (TaskManagerSettings.Column_IOWriteBytes)
  213. SendMessageW(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_SETCHECK, BST_CHECKED, 0);
  214. if (TaskManagerSettings.Column_IOOtherBytes)
  215. SendMessageW(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_SETCHECK, BST_CHECKED, 0);
  216. return TRUE;
  217. case WM_COMMAND:
  218. if (LOWORD(wParam) == IDCANCEL)
  219. {
  220. EndDialog(hDlg, LOWORD(wParam));
  221. return TRUE;
  222. }
  223. if (LOWORD(wParam) == IDOK)
  224. {
  225. TaskManagerSettings.Column_ImageName = SendMessageW(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0);
  226. TaskManagerSettings.Column_PID = SendMessageW(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
  227. TaskManagerSettings.Column_UserName = SendMessageW(GetDlgItem(hDlg, IDC_USERNAME), BM_GETCHECK, 0, 0);
  228. TaskManagerSettings.Column_SessionID = SendMessageW(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
  229. TaskManagerSettings.Column_CPUUsage = SendMessageW(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_GETCHECK, 0, 0);
  230. TaskManagerSettings.Column_CPUTime = SendMessageW(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
  231. TaskManagerSettings.Column_MemoryUsage = SendMessageW(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_GETCHECK, 0, 0);
  232. TaskManagerSettings.Column_PeakMemoryUsage = SendMessageW(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
  233. TaskManagerSettings.Column_MemoryUsageDelta = SendMessageW(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_GETCHECK, 0, 0);
  234. TaskManagerSettings.Column_PageFaults = SendMessageW(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
  235. TaskManagerSettings.Column_PageFaultsDelta = SendMessageW(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_GETCHECK, 0, 0);
  236. TaskManagerSettings.Column_VirtualMemorySize = SendMessageW(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
  237. TaskManagerSettings.Column_PagedPool = SendMessageW(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_GETCHECK, 0, 0);
  238. TaskManagerSettings.Column_NonPagedPool = SendMessageW(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
  239. TaskManagerSettings.Column_BasePriority = SendMessageW(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_GETCHECK, 0, 0);
  240. TaskManagerSettings.Column_HandleCount = SendMessageW(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
  241. TaskManagerSettings.Column_ThreadCount = SendMessageW(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_GETCHECK, 0, 0);
  242. TaskManagerSettings.Column_USERObjects = SendMessageW(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
  243. TaskManagerSettings.Column_GDIObjects = SendMessageW(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_GETCHECK, 0, 0);
  244. TaskManagerSettings.Column_IOReads = SendMessageW(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
  245. TaskManagerSettings.Column_IOWrites = SendMessageW(GetDlgItem(hDlg, IDC_IOWRITES), BM_GETCHECK, 0, 0);
  246. TaskManagerSettings.Column_IOOther = SendMessageW(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
  247. TaskManagerSettings.Column_IOReadBytes = SendMessageW(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_GETCHECK, 0, 0);
  248. TaskManagerSettings.Column_IOWriteBytes = SendMessageW(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
  249. TaskManagerSettings.Column_IOOtherBytes = SendMessageW(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
  250. EndDialog(hDlg, LOWORD(wParam));
  251. return TRUE;
  252. }
  253. break;
  254. }
  255. return 0;
  256. }
  257. void SaveColumnSettings(void)
  258. {
  259. HDITEMW hditem;
  260. int i;
  261. WCHAR text[256];
  262. int size;
  263. /* Reset column data */
  264. for (i=0; i<25; i++)
  265. TaskManagerSettings.ColumnOrderArray[i] = i;
  266. TaskManagerSettings.Column_ImageName = FALSE;
  267. TaskManagerSettings.Column_PID = FALSE;
  268. TaskManagerSettings.Column_CPUUsage = FALSE;
  269. TaskManagerSettings.Column_CPUTime = FALSE;
  270. TaskManagerSettings.Column_MemoryUsage = FALSE;
  271. TaskManagerSettings.Column_MemoryUsageDelta = FALSE;
  272. TaskManagerSettings.Column_PeakMemoryUsage = FALSE;
  273. TaskManagerSettings.Column_PageFaults = FALSE;
  274. TaskManagerSettings.Column_USERObjects = FALSE;
  275. TaskManagerSettings.Column_IOReads = FALSE;
  276. TaskManagerSettings.Column_IOReadBytes = FALSE;
  277. TaskManagerSettings.Column_SessionID = FALSE;
  278. TaskManagerSettings.Column_UserName = FALSE;
  279. TaskManagerSettings.Column_PageFaultsDelta = FALSE;
  280. TaskManagerSettings.Column_VirtualMemorySize = FALSE;
  281. TaskManagerSettings.Column_PagedPool = FALSE;
  282. TaskManagerSettings.Column_NonPagedPool = FALSE;
  283. TaskManagerSettings.Column_BasePriority = FALSE;
  284. TaskManagerSettings.Column_HandleCount = FALSE;
  285. TaskManagerSettings.Column_ThreadCount = FALSE;
  286. TaskManagerSettings.Column_GDIObjects = FALSE;
  287. TaskManagerSettings.Column_IOWrites = FALSE;
  288. TaskManagerSettings.Column_IOWriteBytes = FALSE;
  289. TaskManagerSettings.Column_IOOther = FALSE;
  290. TaskManagerSettings.Column_IOOtherBytes = FALSE;
  291. TaskManagerSettings.ColumnSizeArray[0] = 105;
  292. TaskManagerSettings.ColumnSizeArray[1] = 50;
  293. TaskManagerSettings.ColumnSizeArray[2] = 107;
  294. TaskManagerSettings.ColumnSizeArray[3] = 70;
  295. TaskManagerSettings.ColumnSizeArray[4] = 35;
  296. TaskManagerSettings.ColumnSizeArray[5] = 70;
  297. TaskManagerSettings.ColumnSizeArray[6] = 70;
  298. TaskManagerSettings.ColumnSizeArray[7] = 100;
  299. TaskManagerSettings.ColumnSizeArray[8] = 70;
  300. TaskManagerSettings.ColumnSizeArray[9] = 70;
  301. TaskManagerSettings.ColumnSizeArray[10] = 70;
  302. TaskManagerSettings.ColumnSizeArray[11] = 70;
  303. TaskManagerSettings.ColumnSizeArray[12] = 70;
  304. TaskManagerSettings.ColumnSizeArray[13] = 70;
  305. TaskManagerSettings.ColumnSizeArray[14] = 60;
  306. TaskManagerSettings.ColumnSizeArray[15] = 60;
  307. TaskManagerSettings.ColumnSizeArray[16] = 60;
  308. TaskManagerSettings.ColumnSizeArray[17] = 60;
  309. TaskManagerSettings.ColumnSizeArray[18] = 60;
  310. TaskManagerSettings.ColumnSizeArray[19] = 70;
  311. TaskManagerSettings.ColumnSizeArray[20] = 70;
  312. TaskManagerSettings.ColumnSizeArray[21] = 70;
  313. TaskManagerSettings.ColumnSizeArray[22] = 70;
  314. TaskManagerSettings.ColumnSizeArray[23] = 70;
  315. TaskManagerSettings.ColumnSizeArray[24] = 70;
  316. /* Get header order */
  317. size = SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
  318. SendMessageW(hProcessPageHeaderCtrl, HDM_GETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
  319. /* Get visible columns */
  320. for (i=0; i<SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); i++) {
  321. memset(&hditem, 0, sizeof(HDITEMW));
  322. hditem.mask = HDI_TEXT|HDI_WIDTH;
  323. hditem.pszText = text;
  324. hditem.cchTextMax = 256;
  325. SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMW, i, (LPARAM) &hditem);
  326. if (lstrcmpW(text, wszImageName) == 0)
  327. {
  328. TaskManagerSettings.Column_ImageName = TRUE;
  329. TaskManagerSettings.ColumnSizeArray[0] = hditem.cxy;
  330. }
  331. if (lstrcmpW(text, wszPID) == 0)
  332. {
  333. TaskManagerSettings.Column_PID = TRUE;
  334. TaskManagerSettings.ColumnSizeArray[1] = hditem.cxy;
  335. }
  336. if (lstrcmpW(text, wszUserName) == 0)
  337. {
  338. TaskManagerSettings.Column_UserName = TRUE;
  339. TaskManagerSettings.ColumnSizeArray[2] = hditem.cxy;
  340. }
  341. if (lstrcmpW(text, wszSessionID) == 0)
  342. {
  343. TaskManagerSettings.Column_SessionID = TRUE;
  344. TaskManagerSettings.ColumnSizeArray[3] = hditem.cxy;
  345. }
  346. if (lstrcmpW(text, wszCPU) == 0)
  347. {
  348. TaskManagerSettings.Column_CPUUsage = TRUE;
  349. TaskManagerSettings.ColumnSizeArray[4] = hditem.cxy;
  350. }
  351. if (lstrcmpW(text, wszCPUTime) == 0)
  352. {
  353. TaskManagerSettings.Column_CPUTime = TRUE;
  354. TaskManagerSettings.ColumnSizeArray[5] = hditem.cxy;
  355. }
  356. if (lstrcmpW(text, wszMemUsage) == 0)
  357. {
  358. TaskManagerSettings.Column_MemoryUsage = TRUE;
  359. TaskManagerSettings.ColumnSizeArray[6] = hditem.cxy;
  360. }
  361. if (lstrcmpW(text, wszPeakMemUsage) == 0)
  362. {
  363. TaskManagerSettings.Column_PeakMemoryUsage = TRUE;
  364. TaskManagerSettings.ColumnSizeArray[7] = hditem.cxy;
  365. }
  366. if (lstrcmpW(text, wszMemDelta) == 0)
  367. {
  368. TaskManagerSettings.Column_MemoryUsageDelta = TRUE;
  369. TaskManagerSettings.ColumnSizeArray[8] = hditem.cxy;
  370. }
  371. if (lstrcmpW(text, wszPageFaults) == 0)
  372. {
  373. TaskManagerSettings.Column_PageFaults = TRUE;
  374. TaskManagerSettings.ColumnSizeArray[9] = hditem.cxy;
  375. }
  376. if (lstrcmpW(text, wszPFDelta) == 0)
  377. {
  378. TaskManagerSettings.Column_PageFaultsDelta = TRUE;
  379. TaskManagerSettings.ColumnSizeArray[10] = hditem.cxy;
  380. }
  381. if (lstrcmpW(text, wszVMSize) == 0)
  382. {
  383. TaskManagerSettings.Column_VirtualMemorySize = TRUE;
  384. TaskManagerSettings.ColumnSizeArray[11] = hditem.cxy;
  385. }
  386. if (lstrcmpW(text, wszPagedPool) == 0)
  387. {
  388. TaskManagerSettings.Column_PagedPool = TRUE;
  389. TaskManagerSettings.ColumnSizeArray[12] = hditem.cxy;
  390. }
  391. if (lstrcmpW(text, wszNPPool) == 0)
  392. {
  393. TaskManagerSettings.Column_NonPagedPool = TRUE;
  394. TaskManagerSettings.ColumnSizeArray[13] = hditem.cxy;
  395. }
  396. if (lstrcmpW(text, wszBasePri) == 0)
  397. {
  398. TaskManagerSettings.Column_BasePriority = TRUE;
  399. TaskManagerSettings.ColumnSizeArray[14] = hditem.cxy;
  400. }
  401. if (lstrcmpW(text, wszHandles) == 0)
  402. {
  403. TaskManagerSettings.Column_HandleCount = TRUE;
  404. TaskManagerSettings.ColumnSizeArray[15] = hditem.cxy;
  405. }
  406. if (lstrcmpW(text, wszThreads) == 0)
  407. {
  408. TaskManagerSettings.Column_ThreadCount = TRUE;
  409. TaskManagerSettings.ColumnSizeArray[16] = hditem.cxy;
  410. }
  411. if (lstrcmpW(text, wszUSERObjects) == 0)
  412. {
  413. TaskManagerSettings.Column_USERObjects = TRUE;
  414. TaskManagerSettings.ColumnSizeArray[17] = hditem.cxy;
  415. }
  416. if (lstrcmpW(text, wszGDIObjects) == 0)
  417. {
  418. TaskManagerSettings.Column_GDIObjects = TRUE;
  419. TaskManagerSettings.ColumnSizeArray[18] = hditem.cxy;
  420. }
  421. if (lstrcmpW(text, wszIOReads) == 0)
  422. {
  423. TaskManagerSettings.Column_IOReads = TRUE;
  424. TaskManagerSettings.ColumnSizeArray[19] = hditem.cxy;
  425. }
  426. if (lstrcmpW(text, wszIOWrites) == 0)
  427. {
  428. TaskManagerSettings.Column_IOWrites = TRUE;
  429. TaskManagerSettings.ColumnSizeArray[20] = hditem.cxy;
  430. }
  431. if (lstrcmpW(text, wszIOOther) == 0)
  432. {
  433. TaskManagerSettings.Column_IOOther = TRUE;
  434. TaskManagerSettings.ColumnSizeArray[21] = hditem.cxy;
  435. }
  436. if (lstrcmpW(text, wszIOReadBytes) == 0)
  437. {
  438. TaskManagerSettings.Column_IOReadBytes = TRUE;
  439. TaskManagerSettings.ColumnSizeArray[22] = hditem.cxy;
  440. }
  441. if (lstrcmpW(text, wszIOWriteBytes) == 0)
  442. {
  443. TaskManagerSettings.Column_IOWriteBytes = TRUE;
  444. TaskManagerSettings.ColumnSizeArray[23] = hditem.cxy;
  445. }
  446. if (lstrcmpW(text, wszIOOtherBytes) == 0)
  447. {
  448. TaskManagerSettings.Column_IOOtherBytes = TRUE;
  449. TaskManagerSettings.ColumnSizeArray[24] = hditem.cxy;
  450. }
  451. }
  452. }
  453. void ProcessPage_OnViewSelectColumns(void)
  454. {
  455. int i;
  456. if (DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_COLUMNS_DIALOG), hMainWnd, ColumnsDialogWndProc) == IDOK)
  457. {
  458. for (i=SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0)-1; i>=0; i--)
  459. {
  460. SendMessageW(hProcessPageListCtrl, LVM_DELETECOLUMN, 0, i);
  461. }
  462. for (i=0; i<25; i++)
  463. TaskManagerSettings.ColumnOrderArray[i] = i;
  464. TaskManagerSettings.ColumnSizeArray[0] = 105;
  465. TaskManagerSettings.ColumnSizeArray[1] = 50;
  466. TaskManagerSettings.ColumnSizeArray[2] = 107;
  467. TaskManagerSettings.ColumnSizeArray[3] = 70;
  468. TaskManagerSettings.ColumnSizeArray[4] = 35;
  469. TaskManagerSettings.ColumnSizeArray[5] = 70;
  470. TaskManagerSettings.ColumnSizeArray[6] = 70;
  471. TaskManagerSettings.ColumnSizeArray[7] = 100;
  472. TaskManagerSettings.ColumnSizeArray[8] = 70;
  473. TaskManagerSettings.ColumnSizeArray[9] = 70;
  474. TaskManagerSettings.ColumnSizeArray[10] = 70;
  475. TaskManagerSettings.ColumnSizeArray[11] = 70;
  476. TaskManagerSettings.ColumnSizeArray[12] = 70;
  477. TaskManagerSettings.ColumnSizeArray[13] = 70;
  478. TaskManagerSettings.ColumnSizeArray[14] = 60;
  479. TaskManagerSettings.ColumnSizeArray[15] = 60;
  480. TaskManagerSettings.ColumnSizeArray[16] = 60;
  481. TaskManagerSettings.ColumnSizeArray[17] = 60;
  482. TaskManagerSettings.ColumnSizeArray[18] = 60;
  483. TaskManagerSettings.ColumnSizeArray[19] = 70;
  484. TaskManagerSettings.ColumnSizeArray[20] = 70;
  485. TaskManagerSettings.ColumnSizeArray[21] = 70;
  486. TaskManagerSettings.ColumnSizeArray[22] = 70;
  487. TaskManagerSettings.ColumnSizeArray[23] = 70;
  488. TaskManagerSettings.ColumnSizeArray[24] = 70;
  489. AddColumns();
  490. }
  491. }
  492. void UpdateColumnDataHints(void)
  493. {
  494. HDITEMW hditem;
  495. WCHAR text[256];
  496. ULONG Index;
  497. for (Index=0; Index<(ULONG)SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); Index++)
  498. {
  499. memset(&hditem, 0, sizeof(HDITEMW));
  500. hditem.mask = HDI_TEXT;
  501. hditem.pszText = text;
  502. hditem.cchTextMax = 260;
  503. SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMW, Index, (LPARAM) &hditem);
  504. if (lstrcmpW(text, wszImageName) == 0)
  505. ColumnDataHints[Index] = COLUMN_IMAGENAME;
  506. if (lstrcmpW(text, wszPID) == 0)
  507. ColumnDataHints[Index] = COLUMN_PID;
  508. if (lstrcmpW(text, wszUserName) == 0)
  509. ColumnDataHints[Index] = COLUMN_USERNAME;
  510. if (lstrcmpW(text, wszSessionID) == 0)
  511. ColumnDataHints[Index] = COLUMN_SESSIONID;
  512. if (lstrcmpW(text, wszCPU) == 0)
  513. ColumnDataHints[Index] = COLUMN_CPUUSAGE;
  514. if (lstrcmpW(text, wszCPUTime) == 0)
  515. ColumnDataHints[Index] = COLUMN_CPUTIME;
  516. if (lstrcmpW(text, wszMemUsage) == 0)
  517. ColumnDataHints[Index] = COLUMN_MEMORYUSAGE;
  518. if (lstrcmpW(text, wszPeakMemUsage) == 0)
  519. ColumnDataHints[Index] = COLUMN_PEAKMEMORYUSAGE;
  520. if (lstrcmpW(text, wszMemDelta) == 0)
  521. ColumnDataHints[Index] = COLUMN_MEMORYUSAGEDELTA;
  522. if (lstrcmpW(text, wszPageFaults) == 0)
  523. ColumnDataHints[Index] = COLUMN_PAGEFAULTS;
  524. if (lstrcmpW(text, wszPFDelta) == 0)
  525. ColumnDataHints[Index] = COLUMN_PAGEFAULTSDELTA;
  526. if (lstrcmpW(text, wszVMSize) == 0)
  527. ColumnDataHints[Index] = COLUMN_VIRTUALMEMORYSIZE;
  528. if (lstrcmpW(text, wszPagedPool) == 0)
  529. ColumnDataHints[Index] = COLUMN_PAGEDPOOL;
  530. if (lstrcmpW(text, wszNPPool) == 0)
  531. ColumnDataHints[Index] = COLUMN_NONPAGEDPOOL;
  532. if (lstrcmpW(text, wszBasePri) == 0)
  533. ColumnDataHints[Index] = COLUMN_BASEPRIORITY;
  534. if (lstrcmpW(text, wszHandles) == 0)
  535. ColumnDataHints[Index] = COLUMN_HANDLECOUNT;
  536. if (lstrcmpW(text, wszThreads) == 0)
  537. ColumnDataHints[Index] = COLUMN_THREADCOUNT;
  538. if (lstrcmpW(text, wszUSERObjects) == 0)
  539. ColumnDataHints[Index] = COLUMN_USEROBJECTS;
  540. if (lstrcmpW(text, wszGDIObjects) == 0)
  541. ColumnDataHints[Index] = COLUMN_GDIOBJECTS;
  542. if (lstrcmpW(text, wszIOReads) == 0)
  543. ColumnDataHints[Index] = COLUMN_IOREADS;
  544. if (lstrcmpW(text, wszIOWrites) == 0)
  545. ColumnDataHints[Index] = COLUMN_IOWRITES;
  546. if (lstrcmpW(text, wszIOOther) == 0)
  547. ColumnDataHints[Index] = COLUMN_IOOTHER;
  548. if (lstrcmpW(text, wszIOReadBytes) == 0)
  549. ColumnDataHints[Index] = COLUMN_IOREADBYTES;
  550. if (lstrcmpW(text, wszIOWriteBytes) == 0)
  551. ColumnDataHints[Index] = COLUMN_IOWRITEBYTES;
  552. if (lstrcmpW(text, wszIOOtherBytes) == 0)
  553. ColumnDataHints[Index] = COLUMN_IOOTHERBYTES;
  554. }
  555. }