ReactOS  0.4.14-dev-552-g2fad488
column.c
Go to the documentation of this file.
1 /*
2  * ReactOS Task Manager
3  *
4  * column.c
5  *
6  * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
7  * 2005 Klemens Friedl <frik85@reactos.at>
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 Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include "precomp.h"
25 
27 
28 #define DECLARE_COLUMN_PRESET(_name, _size, _state) \
29  { IDS_TAB_##_name, IDC_##_name, _size, _state },
30 
32  DECLARE_COLUMN_PRESET(IMAGENAME, 105, TRUE)
33  DECLARE_COLUMN_PRESET(PID, 50, TRUE)
34  DECLARE_COLUMN_PRESET(USERNAME, 107, FALSE)
35  DECLARE_COLUMN_PRESET(SESSIONID, 70, FALSE)
36  DECLARE_COLUMN_PRESET(CPUUSAGE, 35, TRUE)
37  DECLARE_COLUMN_PRESET(CPUTIME, 70, TRUE)
38  DECLARE_COLUMN_PRESET(MEMORYUSAGE, 70, TRUE)
39  DECLARE_COLUMN_PRESET(PEAKMEMORYUSAGE, 100, FALSE)
40  DECLARE_COLUMN_PRESET(MEMORYUSAGEDELTA, 70, FALSE)
41  DECLARE_COLUMN_PRESET(PAGEFAULTS, 70, FALSE)
42  DECLARE_COLUMN_PRESET(PAGEFAULTSDELTA, 70, FALSE)
43  DECLARE_COLUMN_PRESET(VIRTUALMEMORYSIZE, 70, FALSE)
46  DECLARE_COLUMN_PRESET(BASEPRIORITY, 60, FALSE)
47  DECLARE_COLUMN_PRESET(HANDLECOUNT, 60, FALSE)
48  DECLARE_COLUMN_PRESET(THREADCOUNT, 60, FALSE)
49  DECLARE_COLUMN_PRESET(USEROBJECTS, 60, FALSE)
50  DECLARE_COLUMN_PRESET(GDIOBJECTS, 60, FALSE)
51  DECLARE_COLUMN_PRESET(IOREADS, 70, FALSE)
52  DECLARE_COLUMN_PRESET(IOWRITES, 70, FALSE)
53  DECLARE_COLUMN_PRESET(IOOTHER, 70, FALSE)
54  DECLARE_COLUMN_PRESET(IOREADBYTES, 70, FALSE)
55  DECLARE_COLUMN_PRESET(IOWRITEBYTES, 70, FALSE)
56  DECLARE_COLUMN_PRESET(IOOTHERBYTES, 70, FALSE)
57  DECLARE_COLUMN_PRESET(COMMANDLINE, 450, FALSE)
58 };
59 
60 static int InsertColumn(int nCol, LPCWSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem);
62 
63 void AddColumns(void)
64 {
65  LRESULT size;
66  WCHAR szTemp[256];
67  unsigned int n;
68 
69  for (n=0; n<COLUMN_NMAX; n++) {
71  LoadStringW(hInst, ColumnPresets[n].dwIdsName, szTemp, sizeof(szTemp)/sizeof(WCHAR));
73  }
74  }
75 
78 
80 }
81 
82 static int InsertColumn(int nCol, LPCWSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
83 {
85 
86  column.mask = LVCF_TEXT|LVCF_FMT;
87  column.pszText = (LPWSTR)lpszColumnHeading;
88  column.fmt = nFormat;
89 
90  if (nWidth != -1)
91  {
92  column.mask |= LVCF_WIDTH;
93  column.cx = nWidth;
94  }
95 
96  if (nSubItem != -1)
97  {
98  column.mask |= LVCF_SUBITEM;
99  column.iSubItem = nSubItem;
100  }
101 
103 }
104 
106 {
107  HDITEM hditem;
108  int i, n;
109  WCHAR text[260];
110  WCHAR szTemp[256];
111  LRESULT size;
112 
113  /* Reset column data */
114  for (i=0; i<COLUMN_NMAX; i++) {
118  }
119 
120  /* Get header order */
123 
124  /* Get visible columns */
125  for (i = 0; i < SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); i++) {
126  memset(&hditem, 0, sizeof(HDITEM));
127 
128  hditem.mask = HDI_TEXT|HDI_WIDTH;
129  hditem.pszText = text;
130  hditem.cchTextMax = 260;
131 
133 
134  for (n = 0; n < COLUMN_NMAX; n++) {
135  LoadStringW(hInst, ColumnPresets[n].dwIdsName, szTemp, sizeof(szTemp)/sizeof(WCHAR));
136  if (_wcsicmp(text, szTemp) == 0)
137  {
139  TaskManagerSettings.ColumnSizeArray[n] = hditem.cxy;
140  }
141  }
142  }
143 }
144 
146 {
147  int i;
148 
150  {
152  {
154  }
155 
156  for (i=0; i<COLUMN_NMAX; i++) {
159  }
160 
161  AddColumns();
162  }
163 }
164 
167 {
168  unsigned int i;
169 
170  switch (message)
171  {
172  case WM_INITDIALOG:
173 
174  for (i=0; i<COLUMN_NMAX; i++) {
176  CheckDlgButton(hDlg, ColumnPresets[i].dwIdcCtrl, BST_CHECKED);
177  }
178  return TRUE;
179 
180  case WM_COMMAND:
181 
182  if (LOWORD(wParam) == IDCANCEL)
183  {
184  EndDialog(hDlg, LOWORD(wParam));
185  return TRUE;
186  }
187 
188  if (LOWORD(wParam) == IDOK)
189  {
190  for (i=0; i<COLUMN_NMAX; i++)
192 
193  EndDialog(hDlg, LOWORD(wParam));
194  return TRUE;
195  }
196 
197  break;
198  }
199 
200  return 0;
201 }
202 
204 {
205  HDITEM hditem;
206  WCHAR text[260];
207  ULONG Index;
208  ULONG uItems;
209  WCHAR szTemp[256];
210  UINT i;
211 
213 
214  for (Index=0; Index<uItems; Index++)
215  {
216  memset(&hditem, 0, sizeof(HDITEM));
217 
218  hditem.mask = HDI_TEXT;
219  hditem.pszText = text;
220  hditem.cchTextMax = 260;
221 
223 
224  for (i=0; i<COLUMN_NMAX; i++) {
225  LoadStringW(hInst, ColumnPresets[i].dwIdsName, szTemp, sizeof(szTemp)/sizeof(WCHAR));
226  if (_wcsicmp(text, szTemp) == 0)
228  }
229  }
230 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define COLUMN_NMAX
Definition: column.h:51
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2583
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define LVCF_TEXT
Definition: commctrl.h:2584
#define ListView_DeleteColumn(hwnd, iCol)
Definition: commctrl.h:2635
const WCHAR * text
Definition: package.c:1827
#define CALLBACK
Definition: compat.h:27
GLdouble n
Definition: glext.h:7729
#define LVCFMT_LEFT
Definition: commctrl.h:2594
int ColumnSizeArray[COLUMN_NMAX]
Definition: taskmgr.h:82
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:62
#define HDI_TEXT
Definition: commctrl.h:700
#define HDITEM
Definition: commctrl.h:693
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define NONPAGEDPOOL
Definition: utils.h:306
#define LVCF_SUBITEM
Definition: commctrl.h:2585
#define IDD_COLUMNS_DIALOG
Definition: resource.h:24
#define LVCOLUMN
Definition: commctrl.h:2577
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2632
#define HDM_GETITEMCOUNT
Definition: commctrl.h:729
#define DECLARE_COLUMN_PRESET(_name, _size, _state)
Definition: column.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND hProcessPageHeaderCtrl
Definition: procpage.c:39
const PresetColumnEntry ColumnPresets[COLUMN_NMAX]
Definition: column.c:31
void SaveColumnSettings(void)
Definition: column.c:105
LONG_PTR LPARAM
Definition: windef.h:208
#define PAGEDPOOL
Definition: utils.h:305
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4374
void UpdateColumnDataHints(void)
Definition: column.c:203
GLsizeiptr size
Definition: glext.h:5919
#define HDM_SETORDERARRAY
Definition: commctrl.h:805
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT ColumnDataHints[COLUMN_NMAX]
Definition: column.c:26
static const UCHAR Index[8]
Definition: usbohci.c:18
BOOL Columns[COLUMN_NMAX]
Definition: taskmgr.h:80
#define HDM_GETORDERARRAY
Definition: commctrl.h:802
#define Header_GetItemCount(hwndHD)
Definition: commctrl.h:730
INT_PTR CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: column.c:166
HWND hMainWnd
Definition: magnifier.c:32
#define WM_COMMAND
Definition: winuser.h:1722
#define LVCF_FMT
Definition: commctrl.h:2582
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define BST_CHECKED
Definition: winuser.h:197
unsigned int ULONG
Definition: retypes.h:1
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
#define HDM_GETITEM
Definition: commctrl.h:745
static int InsertColumn(int nCol, LPCWSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
Definition: column.c:82
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
int ColumnOrderArray[COLUMN_NMAX]
Definition: taskmgr.h:81
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
void ProcessPage_OnViewSelectColumns(void)
Definition: column.c:145
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define HDI_WIDTH
Definition: commctrl.h:698
#define memset(x, y, z)
Definition: compat.h:39
HWND hProcessPageListCtrl
Definition: procpage.c:38
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
void AddColumns(void)
Definition: column.c:63