ReactOS  0.4.12-dev-18-gf469aca
listview.c File Reference
#include "precomp.h"
Include dependency graph for listview.c:

Go to the source code of this file.

Classes

struct  _COLUMN_LIST
 

Typedefs

typedef struct _COLUMN_LIST COLUMN_LIST
 

Functions

VOID SetListViewStyle (HWND hListView, DWORD View)
 
VOID ListViewSelectionChanged (PMAIN_WND_INFO Info, LPNMLISTVIEW pnmv)
 
VOID ChangeListViewText (PMAIN_WND_INFO Info, ENUM_SERVICE_STATUS_PROCESS *pService, UINT Column)
 
BOOL RefreshServiceList (PMAIN_WND_INFO Info)
 
static VOID InitListViewImage (PMAIN_WND_INFO Info)
 
BOOL CreateListView (PMAIN_WND_INFO Info)
 

Variables

static const COLUMN_LIST Columns []
 

Typedef Documentation

◆ COLUMN_LIST

Function Documentation

◆ ChangeListViewText()

VOID ChangeListViewText ( PMAIN_WND_INFO  Info,
ENUM_SERVICE_STATUS_PROCESS pService,
UINT  Column 
)

Definition at line 105 of file listview.c.

Referenced by GeneralPageProc(), MainWndCommand(), RefreshServiceList(), and SaveDlgInfo().

108 {
109  LVFINDINFO lvfi;
110  LVITEM lvItem;
111  INT index;
112 
113  lvfi.flags = LVFI_PARAM;
114  lvfi.lParam = (LPARAM)pService;
115  index = ListView_FindItem(Info->hListView,
116  -1,
117  &lvfi);
118  if (index != -1)
119  {
120  lvItem.iItem = index;
121  lvItem.iSubItem = Column;
122 
123  switch (Column)
124  {
125  case LVNAME:
126  {
127  LPQUERY_SERVICE_CONFIG lpServiceConfig;
128 
129  lpServiceConfig = GetServiceConfig(pService->lpServiceName);
130  if (lpServiceConfig)
131  {
132  lvItem.pszText = lpServiceConfig->lpDisplayName;
133  SendMessage(Info->hListView,
135  lvItem.iItem,
136  (LPARAM)&lvItem);
137 
139  0,
140  lpServiceConfig);
141  }
142  }
143  break;
144 
145  case LVDESC:
146  {
147  LPWSTR lpDescription;
148 
149  lpDescription = GetServiceDescription(pService->lpServiceName);
150 
151  lvItem.pszText = lpDescription;
152  SendMessage(Info->hListView,
154  lvItem.iItem,
155  (LPARAM) &lvItem);
156 
158  0,
159  lpDescription);
160  }
161  break;
162 
163  case LVSTATUS:
164  {
165  WCHAR szStatus[64];
166 
168  {
171  szStatus,
172  sizeof(szStatus) / sizeof(WCHAR));
173  }
174  else
175  {
176  szStatus[0] = 0;
177  }
178 
179  lvItem.pszText = szStatus;
180  SendMessageW(Info->hListView,
182  lvItem.iItem,
183  (LPARAM) &lvItem);
184  }
185  break;
186 
187  case LVSTARTUP:
188  {
189  LPQUERY_SERVICE_CONFIGW lpServiceConfig;
190  LPWSTR lpStartup = NULL;
191  DWORD StringId = 0;
192 
193  lpServiceConfig = GetServiceConfig(pService->lpServiceName);
194 
195  if (lpServiceConfig)
196  {
197  switch (lpServiceConfig->dwStartType)
198  {
199  case 2: StringId = IDS_SERVICES_AUTO; break;
200  case 3: StringId = IDS_SERVICES_MAN; break;
201  case 4: StringId = IDS_SERVICES_DIS; break;
202  }
203  }
204 
205  if (StringId)
206  AllocAndLoadString(&lpStartup,
207  hInstance,
208  StringId);
209 
210  lvItem.pszText = lpStartup;
211  SendMessageW(Info->hListView,
213  lvItem.iItem,
214  (LPARAM)&lvItem);
215 
216  LocalFree(lpStartup);
218  0,
219  lpServiceConfig);
220  }
221  break;
222 
223  case LVLOGONAS:
224  {
225  LPQUERY_SERVICE_CONFIG lpServiceConfig;
226 
227  lpServiceConfig = GetServiceConfig(pService->lpServiceName);
228  if (lpServiceConfig)
229  {
230  lvItem.pszText = lpServiceConfig->lpServiceStartName;
231  SendMessageW(Info->hListView,
233  lvItem.iItem,
234  (LPARAM)&lvItem);
235 
237  0,
238  lpServiceConfig);
239  }
240  }
241  break;
242  }
243  }
244 }
#define LVSTARTUP
Definition: precomp.h:30
LPWSTR GetServiceDescription(LPWSTR lpServiceName)
Definition: query.c:135
LPSTR lpServiceStartName
Definition: winsvc.h:152
__wchar_t WCHAR
Definition: xmlstorage.h:180
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define LVM_SETITEMTEXT
Definition: commctrl.h:2659
#define LVFI_PARAM
Definition: commctrl.h:2406
HINSTANCE hInstance
Definition: charmap.c:20
LONG_PTR LPARAM
Definition: windef.h:208
#define LVSTATUS
Definition: precomp.h:29
#define SERVICE_RUNNING
Definition: winsvc.h:24
smooth NULL
Definition: ftsmooth.c:416
#define IDS_SERVICES_DIS
Definition: resource.h:63
#define IDS_SERVICES_STARTED
Definition: resource.h:59
static const WCHAR szStatus[]
Definition: http.c:73
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LVLOGONAS
Definition: precomp.h:31
#define index(s, c)
Definition: various.h:29
LPQUERY_SERVICE_CONFIG GetServiceConfig(LPWSTR lpServiceName)
Definition: query.c:29
HANDLE ProcessHeap
Definition: servman.c:15
#define LVDESC
Definition: precomp.h:28
#define LVM_SETITEMTEXTW
Definition: commctrl.h:2657
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LVFINDINFO
Definition: commctrl.h:2433
#define IDS_SERVICES_MAN
Definition: resource.h:62
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2440
#define SendMessage
Definition: winuser.h:5709
#define LVITEM
Definition: commctrl.h:2345
WCHAR * LPWSTR
Definition: xmlstorage.h:184
SERVICE_STATUS_PROCESS ServiceStatusProcess
Definition: winsvc.h:137
#define IDS_SERVICES_AUTO
Definition: resource.h:61
#define LVNAME
Definition: precomp.h:27
#define HeapFree(x, y, z)
Definition: compat.h:394
#define LPARAM
Definition: msvc.h:38
HWND hListView
Definition: precomp.h:49

◆ CreateListView()

BOOL CreateListView ( PMAIN_WND_INFO  Info)

Definition at line 355 of file listview.c.

Referenced by ChildWndProc(), CMainWindow::CreateLayout(), and InitMainWnd().

356 {
357  LVCOLUMNW lvc = { 0 };
358  WCHAR szTemp[256];
359  HDITEM hdi;
360  int i, n;
361 
363  WC_LISTVIEWW,
364  NULL,
367  0, 0, 0, 0,
368  Info->hMainWnd,
370  hInstance,
371  NULL);
372  if (Info->hListView == NULL)
373  {
374  MessageBoxW(Info->hMainWnd,
375  L"Could not create List View.",
376  L"Error",
377  MB_OK | MB_ICONERROR);
378  return FALSE;
379  }
380 
381  Info->hHeader = ListView_GetHeader(Info->hListView);
382 
384  LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);/*LVS_EX_GRIDLINES |*/
385 
387  lvc.fmt = LVCFMT_LEFT;
388  lvc.pszText = szTemp;
389 
390  /* Add columns to the list-view */
391  for (n = 0; n < sizeof(Columns) / sizeof(Columns[0]); n++)
392  {
393  lvc.iSubItem = Columns[n].iSubItem;
394  lvc.cx = Columns[n].cx;
395 
397  Columns[n].idsText,
398  szTemp,
399  sizeof(szTemp) / sizeof(szTemp[0]));
400 
401  i = ListView_InsertColumn(Info->hListView, Columns[n].iSubItem, &lvc);
402 
403  hdi.mask = HDI_LPARAM;
404  hdi.lParam = ORD_ASCENDING;
405  (void)Header_SetItem(Info->hHeader, i, &hdi);
406  }
407 
408  InitListViewImage(Info);
409 
410  /* check the details view menu item */
415  MF_BYCOMMAND);
416 
417  return TRUE;
418 }
#define ID_VIEW_DETAILS
Definition: resource.h:38
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define LVCF_WIDTH
Definition: commctrl.h:2557
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDC_SERVLIST
Definition: resource.h:13
#define LVCF_TEXT
Definition: commctrl.h:2558
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LVS_REPORT
Definition: commctrl.h:2232
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
#define ListView_GetHeader(hwnd)
Definition: commctrl.h:2621
#define WC_LISTVIEWW
Definition: commctrl.h:2227
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
#define LVCFMT_LEFT
Definition: commctrl.h:2568
#define WS_CHILD
Definition: pedump.c:617
#define HDITEM
Definition: commctrl.h:682
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define LBS_NOREDRAW
Definition: pedump.c:680
#define LVCF_SUBITEM
Definition: commctrl.h:2559
GLuint n
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
HINSTANCE hInstance
Definition: charmap.c:20
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2606
int iSubItem
Definition: listview.c:14
#define LVS_SORTASCENDING
Definition: commctrl.h:2238
#define LVS_EX_HEADERDRAGDROP
Definition: commctrl.h:2703
smooth NULL
Definition: ftsmooth.c:416
#define ORD_ASCENDING
Definition: precomp.h:43
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
LPWSTR pszText
Definition: commctrl.h:2537
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2695
static const WCHAR L[]
Definition: oid.c:1087
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define MB_ICONERROR
Definition: winuser.h:781
static VOID InitListViewImage(PMAIN_WND_INFO Info)
Definition: listview.c:299
#define LVCF_FMT
Definition: commctrl.h:2556
static const COLUMN_LIST Columns[]
Definition: listview.c:19
#define WS_BORDER
Definition: pedump.c:625
#define LBS_NOTIFY
Definition: pedump.c:678
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
HWND hMainWnd
Definition: precomp.h:48
#define MB_OK
Definition: winuser.h:784
HWND hHeader
Definition: precomp.h:52
#define HDI_LPARAM
Definition: commctrl.h:691
#define Header_SetItem(hwndHD, i, phdi)
Definition: commctrl.h:743
#define WS_VISIBLE
Definition: pedump.c:620
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 ID_VIEW_LARGE
Definition: resource.h:35
HWND hListView
Definition: precomp.h:49

◆ InitListViewImage()

static VOID InitListViewImage ( PMAIN_WND_INFO  Info)
static

Definition at line 299 of file listview.c.

Referenced by CreateListView().

300 {
301  HICON hSmIconItem, hLgIconItem;
302  HIMAGELIST hSmall, hLarge;
303 
307  1,
308  1);
309  if (hSmall)
310  {
311  hSmIconItem = LoadImageW(hInstance,
313  IMAGE_ICON,
314  16,
315  16,
316  0);
317  if (hSmIconItem)
318  {
319  ImageList_AddIcon(hSmall,
320  hSmIconItem);
322  hSmall,
323  LVSIL_SMALL);
324 
325  DestroyIcon(hSmIconItem);
326  }
327  }
328 
332  1,
333  1);
334  if (hLarge)
335  {
336  hLgIconItem = LoadImageW(hInstance,
338  IMAGE_ICON,
339  32,
340  32,
341  0);
342  if (hLgIconItem)
343  {
344  ImageList_AddIcon(hLarge,
345  hLgIconItem);
347  hLarge,
348  LVSIL_NORMAL);
349  DestroyIcon(hLgIconItem);
350  }
351  }
352 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define IMAGE_ICON
Definition: winuser.h:212
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define LVSIL_SMALL
Definition: commctrl.h:2269
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define SM_CYSMICON
Definition: winuser.h:1003
#define ILC_COLOR32
Definition: commctrl.h:343
HINSTANCE hInstance
Definition: charmap.c:20
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:769
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define SM_CXICON
Definition: winuser.h:962
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2274
int WINAPI GetSystemMetrics(_In_ int)
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:505
#define SM_CXSMICON
Definition: winuser.h:1002
#define SM_CYICON
Definition: winuser.h:963
#define ILC_MASK
Definition: commctrl.h:336
#define LVSIL_NORMAL
Definition: commctrl.h:2268
#define IDI_SM_ICON
Definition: resource.h:66
HWND hListView
Definition: precomp.h:49

◆ ListViewSelectionChanged()

VOID ListViewSelectionChanged ( PMAIN_WND_INFO  Info,
LPNMLISTVIEW  pnmv 
)

Definition at line 48 of file listview.c.

Referenced by MainWndProc().

50 {
52 
53  /* get handle to menu */
54  hMainMenu = GetMenu(Info->hMainWnd);
55 
56  /* activate properties menu item, if not already */
57  if (GetMenuState(hMainMenu,
58  ID_PROP,
60  {
61  EnableMenuItem(hMainMenu,
62  ID_PROP,
63  MF_ENABLED);
65  ID_PROP,
66  MF_ENABLED);
68  ID_PROP,
69  MF_BYCOMMAND);
70  }
71 
72  /* activate delete menu item, if not already */
73  if (GetMenuState(hMainMenu,
74  ID_DELETE,
76  {
77  EnableMenuItem(hMainMenu,
78  ID_DELETE,
79  MF_ENABLED);
81  ID_DELETE,
82  MF_ENABLED);
83  }
84 
85  /* set selected service */
86  Info->SelectedItem = pnmv->iItem;
87 
88  /* get pointer to selected service */
89  Info->pCurrentService = GetSelectedService(Info);
90 
91  /* set current selected service in the status bar */
92  SendMessage(Info->hStatus,
93  SB_SETTEXT,
94  1,
96 
97  /* show the properties button */
98  SendMessage(Info->hTool,
100  ID_PROP,
102 }
#define MF_BYCOMMAND
Definition: winuser.h:202
#define TB_SETSTATE
Definition: commctrl.h:1024
UINT WINAPI GetMenuState(_In_ HMENU, _In_ UINT, _In_ UINT)
ENUM_SERVICE_STATUS_PROCESS * GetSelectedService(PMAIN_WND_INFO Info)
Definition: query.c:13
HWND hStatus
Definition: precomp.h:50
INT SelectedItem
Definition: precomp.h:60
HMENU hMainMenu
Definition: mplay32.c:19
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_DELETE
Definition: resource.h:27
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define MF_ENABLED
Definition: winuser.h:128
HWND hTool
Definition: precomp.h:51
#define SB_SETTEXT
Definition: commctrl.h:1919
HMENU hShortcutMenu
Definition: precomp.h:53
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
ENUM_SERVICE_STATUS_PROCESS * pCurrentService
Definition: precomp.h:57
HWND hMainWnd
Definition: precomp.h:48
#define ID_PROP
Definition: resource.h:17
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SendMessage
Definition: winuser.h:5709
#define TBSTATE_ENABLED
Definition: commctrl.h:944
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

◆ RefreshServiceList()

BOOL RefreshServiceList ( PMAIN_WND_INFO  Info)

Definition at line 247 of file listview.c.

Referenced by MainWndCommand(), and MainWndProc().

248 {
249  ENUM_SERVICE_STATUS_PROCESS *pService;
250  LVITEMW lvItem;
251  DWORD Index;
252 
253  SendMessage (Info->hListView,
254  WM_SETREDRAW,
255  FALSE,
256  0);
257 
259 
260  if (GetServiceList(Info))
261  {
262  for (Index = 0; Index < Info->NumServices; Index++)
263  {
264  INT i;
265 
266  pService = &Info->pAllServices[Index];
267 
268  /* set the display name */
269  ZeroMemory(&lvItem, sizeof(LVITEMW));
270  lvItem.mask = LVIF_TEXT | LVIF_PARAM;
271  lvItem.pszText = pService->lpDisplayName;
272 
273  /* Add the service pointer */
274  lvItem.lParam = (LPARAM)pService;
275 
276  /* add it to the listview */
277  lvItem.iItem = ListView_InsertItem(Info->hListView, &lvItem);
278 
279  /* fill out all the column data */
280  for (i = LVDESC; i <= LVLOGONAS; i++)
281  {
282  ChangeListViewText(Info, pService, i);
283  }
284  }
285 
286  UpdateServiceCount(Info);
287  }
288 
289  /* turn redraw flag on. */
290  SendMessageW(Info->hListView,
291  WM_SETREDRAW,
292  TRUE,
293  0);
294 
295  return TRUE;
296 }
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
VOID UpdateServiceCount(PMAIN_WND_INFO Info)
Definition: mainwnd.c:124
#define WM_SETREDRAW
Definition: winuser.h:1598
#define ZeroMemory
Definition: winbase.h:1635
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
int32_t INT
Definition: typedefs.h:56
DWORD NumServices
Definition: precomp.h:58
#define LVIF_TEXT
Definition: commctrl.h:2279
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LPARAM lParam
Definition: commctrl.h:2338
ENUM_SERVICE_STATUS_PROCESS * pAllServices
Definition: precomp.h:56
BOOL GetServiceList(PMAIN_WND_INFO Info)
Definition: query.c:279
LPWSTR pszText
Definition: commctrl.h:2335
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LVLOGONAS
Definition: precomp.h:31
UINT mask
Definition: commctrl.h:2330
VOID ChangeListViewText(PMAIN_WND_INFO Info, ENUM_SERVICE_STATUS_PROCESS *pService, UINT Column)
Definition: listview.c:105
#define LVDESC
Definition: precomp.h:28
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SendMessage
Definition: winuser.h:5709
#define LVIF_PARAM
Definition: commctrl.h:2281
#define LPARAM
Definition: msvc.h:38
HWND hListView
Definition: precomp.h:49
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2384

◆ SetListViewStyle()

VOID SetListViewStyle ( HWND  hListView,
DWORD  View 
)

Definition at line 34 of file listview.c.

Referenced by MainWndCommand().

36 {
37  DWORD Style = GetWindowLongPtr(hListView, GWL_STYLE);
38 
39  if ((Style & LVS_TYPEMASK) != View)
40  {
41  SetWindowLongPtr(hListView,
42  GWL_STYLE,
43  (Style & ~LVS_TYPEMASK) | View);
44  }
45 }
#define SetWindowLongPtr
Definition: treelist.c:70
const DWORD Style
Definition: appswitch.c:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GWL_STYLE
Definition: winuser.h:846
#define LVS_TYPEMASK
Definition: commctrl.h:2235
#define GetWindowLongPtr
Definition: treelist.c:73

Variable Documentation

◆ Columns

const COLUMN_LIST Columns[]
static
Initial value:
=
{
}
#define IDS_THIRDCOLUMN
Definition: resource.h:44
#define IDS_FITHCOLUMN
Definition: resource.h:46
#define LVSTARTUP
Definition: precomp.h:30
#define IDS_FIRSTCOLUMN
Definition: resource.h:42
#define IDS_FOURTHCOLUMN
Definition: resource.h:45
#define LVSTATUS
Definition: precomp.h:29
#define LVLOGONAS
Definition: precomp.h:31
#define LVDESC
Definition: precomp.h:28
#define IDS_SECONDCOLUMN
Definition: resource.h:43
#define LVNAME
Definition: precomp.h:27

Definition at line 19 of file listview.c.

Referenced by CreateListView(), ScreenDeviceControl(), ScreenWrite(), and WSHGetWinsockMapping().