ReactOS  0.4.15-dev-506-ga3ec01c
groups.c File Reference
#include "usrmgr.h"
Include dependency graph for groups.c:

Go to the source code of this file.

Classes

struct  _GROUP_DATA
 

Typedefs

typedef struct _GROUP_DATA GROUP_DATA
 
typedef struct _GROUP_DATAPGROUP_DATA
 

Functions

static VOID SetGroupsListColumns (HWND hwndListView)
 
static VOID UpdateGroupsList (HWND hwndListView)
 
static VOID UpdateGroupProperties (HWND hwndDlg)
 
INT_PTR CALLBACK NewGroupDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID GroupNew (HWND hwndDlg)
 
static VOID GroupRename (HWND hwndDlg)
 
static BOOL GroupDelete (HWND hwndDlg)
 
static VOID OnGroupsPageInitDialog (HWND hwndDlg)
 
static BOOL OnGroupsPageBeginLabelEdit (LPNMLVDISPINFO pnmv)
 
static BOOL OnGroupsPageEndLabelEdit (LPNMLVDISPINFO pnmv)
 
static BOOL OnGroupsPageNotify (HWND hwndDlg, PGROUP_DATA pGroupData, NMHDR *phdr)
 
INT_PTR CALLBACK GroupsPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Typedef Documentation

◆ GROUP_DATA

◆ PGROUP_DATA

Function Documentation

◆ GroupDelete()

static BOOL GroupDelete ( HWND  hwndDlg)
static

Definition at line 255 of file groups.c.

256 {
257  TCHAR szGroupName[UNLEN];
258  TCHAR szText[256];
259  INT nItem;
260  HWND hwndLV;
262 
263  hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
264  nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
265  if (nItem == -1)
266  return FALSE;
267 
268  /* Get the new group name */
269  ListView_GetItemText(hwndLV,
270  nItem, 0,
271  szGroupName,
272  UNLEN);
273 
274  /* Display a warning message, because the delete operation cannot be reverted */
275  wsprintf(szText, TEXT("Dou you really want to delete the user group \"%s\"?"), szGroupName);
276  if (MessageBox(NULL, szText, TEXT("User Groups"), MB_ICONWARNING | MB_YESNO) == IDNO)
277  return FALSE;
278 
279  /* Delete the group */
280  status = NetLocalGroupDel(NULL, szGroupName);
281  if (status != NERR_Success)
282  {
283  TCHAR szText[256];
284  wsprintf(szText, TEXT("Error: %u"), status);
285  MessageBox(NULL, szText, TEXT("NetLocalGroupDel"), MB_ICONERROR | MB_OK);
286  return FALSE;
287  }
288 
289  /* Delete the group from the list */
290  (void)ListView_DeleteItem(hwndLV, nItem);
291 
292  return TRUE;
293 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2430
#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:49
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2680
#define LVNI_SELECTED
Definition: commctrl.h:2420
int32_t INT
Definition: typedefs.h:57
#define MB_ICONWARNING
Definition: winuser.h:780
#define NERR_Success
Definition: lmerr.h:5
#define MB_YESNO
Definition: winuser.h:811
static const WCHAR szText[]
Definition: dialog.c:139
smooth NULL
Definition: ftsmooth.c:416
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2407
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5797
#define TEXT(s)
Definition: k32.h:26
#define UNLEN
Definition: sspi.c:28
#define MB_OK
Definition: winuser.h:784
NET_API_STATUS WINAPI NetLocalGroupDel(LPCWSTR servername, LPCWSTR groupname)
Definition: local_group.c:677
#define IDNO
Definition: winuser.h:830
#define wsprintf
Definition: winuser.h:5840
static SERVICE_STATUS status
Definition: service.c:31
#define IDC_GROUPS_LIST
Definition: resource.h:16
Definition: ps.c:97

Referenced by GroupsPageProc().

◆ GroupNew()

static VOID GroupNew ( HWND  hwndDlg)
static

Definition at line 190 of file groups.c.

191 {
194  LV_ITEM lvi;
195  INT iItem;
196  HWND hwndLV;
197 
199 
202  hwndDlg,
204  (LPARAM)&group) == IDOK)
205  {
207  1,
208  (LPBYTE)&group,
209  NULL);
210  if (status != NERR_Success)
211  {
212  TCHAR szText[256];
213  wsprintf(szText, TEXT("Error: %u"), status);
214  MessageBox(NULL, szText, TEXT("NetUserAdd"), MB_ICONERROR | MB_OK);
215  return;
216  }
217 
218  hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
219 
220  ZeroMemory(&lvi, sizeof(lvi));
221  lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
222  lvi.pszText = group.lgrpi1_name;
223  lvi.state = 0;
224  lvi.iImage = 0;
225  iItem = ListView_InsertItem(hwndLV, &lvi);
226 
227  ListView_SetItemText(hwndLV, iItem, 1,
228  group.lgrpi1_comment);
229  }
230 
231  if (group.lgrpi1_name)
232  HeapFree(GetProcessHeap(), 0, group.lgrpi1_name);
233 
234  if (group.lgrpi1_comment)
235  HeapFree(GetProcessHeap(), 0, group.lgrpi1_comment);
236 }
INT_PTR CALLBACK NewGroupDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: groups.c:119
#define LV_ITEM
Definition: commctrl.h:2333
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDOK
Definition: winuser.h:824
NET_API_STATUS WINAPI NetLocalGroupAdd(LPCWSTR servername, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: local_group.c:334
#define ZeroMemory
Definition: winbase.h:1648
HINSTANCE hApplet
Definition: access.c:17
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
int32_t INT
Definition: typedefs.h:57
#define IDD_GROUP_NEW
Definition: resource.h:78
#define NERR_Success
Definition: lmerr.h:5
#define LVIF_TEXT
Definition: commctrl.h:2305
unsigned char * LPBYTE
Definition: typedefs.h:53
static const WCHAR szText[]
Definition: dialog.c:139
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
GLboolean GLuint group
Definition: glext.h:11120
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2687
char TCHAR
Definition: xmlstorage.h:189
#define GetProcessHeap()
Definition: compat.h:404
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LVIF_IMAGE
Definition: commctrl.h:2306
#define DialogBoxParam
Definition: winuser.h:5739
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5797
#define TEXT(s)
Definition: k32.h:26
#define MB_OK
Definition: winuser.h:784
#define LVIF_STATE
Definition: commctrl.h:2308
#define wsprintf
Definition: winuser.h:5840
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:403
#define IDC_GROUPS_LIST
Definition: resource.h:16
Definition: ps.c:97

Referenced by GroupsPageProc().

◆ GroupRename()

static VOID GroupRename ( HWND  hwndDlg)
static

Definition at line 240 of file groups.c.

241 {
242  INT nItem;
243  HWND hwndLV;
244 
245  hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
246  nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
247  if (nItem != -1)
248  {
249  (void)ListView_EditLabel(hwndLV, nItem);
250  }
251 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2430
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVNI_SELECTED
Definition: commctrl.h:2420
int32_t INT
Definition: typedefs.h:57
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2536
#define IDC_GROUPS_LIST
Definition: resource.h:16

Referenced by GroupsPageProc().

◆ GroupsPageProc()

INT_PTR CALLBACK GroupsPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 436 of file groups.c.

440 {
441  PGROUP_DATA pGroupData;
442 
445  UNREFERENCED_PARAMETER(hwndDlg);
446 
447 
448  pGroupData = (PGROUP_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
449 
450  switch (uMsg)
451  {
452  case WM_INITDIALOG:
453  pGroupData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GROUP_DATA));
454  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGroupData);
455 
457 
458  OnGroupsPageInitDialog(hwndDlg);
459  SetMenuDefaultItem(GetSubMenu(pGroupData->hPopupMenu, 1),
461  FALSE);
462  break;
463 
464  case WM_COMMAND:
465  switch (LOWORD(wParam))
466  {
467  case IDM_GROUP_NEW:
468  case IDC_GROUPS_ADD:
469  GroupNew(hwndDlg);
470  break;
471 
472  case IDM_GROUP_RENAME:
473  GroupRename(hwndDlg);
474  break;
475 
476  case IDM_GROUP_DELETE:
477  case IDC_GROUPS_REMOVE:
478  GroupDelete(hwndDlg);
479  break;
480 
483  if (GroupProperties(hwndDlg) == IDOK)
484  UpdateGroupProperties(hwndDlg);
485  break;
486  }
487  break;
488 
489  case WM_NOTIFY:
490  return OnGroupsPageNotify(hwndDlg, pGroupData, (NMHDR *)lParam);
491 
492  case WM_DESTROY:
493  DestroyMenu(pGroupData->hPopupMenu);
494  HeapFree(GetProcessHeap(), 0, pGroupData);
495  break;
496  }
497 
498  return FALSE;
499 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDOK
Definition: winuser.h:824
#define IDM_GROUP_NEW
Definition: resource.h:98
static VOID UpdateGroupProperties(HWND hwndDlg)
Definition: groups.c:91
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static BOOL GroupDelete(HWND hwndDlg)
Definition: groups.c:255
HINSTANCE hApplet
Definition: access.c:17
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define IDM_POPUP_GROUP
Definition: resource.h:96
BOOL GroupProperties(HWND hwndDlg)
Definition: groupprops.c:611
HMENU hPopupMenu
Definition: groups.c:14
#define IDC_GROUPS_ADD
Definition: resource.h:38
static VOID GroupRename(HWND hwndDlg)
Definition: groups.c:240
#define WM_DESTROY
Definition: winuser.h:1591
#define IDM_GROUP_RENAME
Definition: resource.h:100
#define IDM_GROUP_DELETE
Definition: resource.h:99
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static VOID GroupNew(HWND hwndDlg)
Definition: groups.c:190
#define IDC_GROUPS_REMOVE
Definition: resource.h:39
#define DWLP_USER
Definition: winuser.h:866
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
static BOOL OnGroupsPageNotify(HWND hwndDlg, PGROUP_DATA pGroupData, NMHDR *phdr)
Definition: groups.c:391
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define IDC_GROUPS_PROPERTIES
Definition: resource.h:40
#define LoadMenu
Definition: winuser.h:5792
#define IDM_GROUP_PROPERTIES
Definition: resource.h:101
static VOID OnGroupsPageInitDialog(HWND hwndDlg)
Definition: groups.c:297
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
struct _GROUP_DATA * PGROUP_DATA
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:403
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by UsrmgrApplet().

◆ NewGroupDlgProc()

INT_PTR CALLBACK NewGroupDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 119 of file groups.c.

123 {
124  PLOCALGROUP_INFO_1 groupInfo;
125  INT nLength;
126 
128 
129  groupInfo = (PLOCALGROUP_INFO_1)GetWindowLongPtr(hwndDlg, DWLP_USER);
130 
131  switch (uMsg)
132  {
133  case WM_INITDIALOG:
134  SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
135  groupInfo = (PLOCALGROUP_INFO_1)lParam;
137  break;
138 
139  case WM_COMMAND:
140  switch (LOWORD(wParam))
141  {
142  case IDC_GROUP_NEW_NAME:
143  if (HIWORD(wParam) == EN_CHANGE)
144  {
146  EnableWindow(GetDlgItem(hwndDlg, IDOK), (nLength > 0));
147  }
148  break;
149 
150  case IDOK:
151  if (!CheckAccountName(hwndDlg, IDC_GROUP_NEW_NAME, NULL))
152  {
155  break;
156  }
157 
159  if (nLength > 0)
160  {
161  groupInfo->lgrpi1_name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
162  GetDlgItemText(hwndDlg, IDC_GROUP_NEW_NAME, groupInfo->lgrpi1_name, nLength + 1);
163  }
164 
166  if (nLength > 0)
167  {
168  groupInfo->lgrpi1_comment = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
170  }
171 
172  EndDialog(hwndDlg, IDOK);
173  break;
174 
175  case IDCANCEL:
176  EndDialog(hwndDlg, IDCANCEL);
177  break;
178  }
179  break;
180 
181  default:
182  return FALSE;
183  }
184 
185  return TRUE;
186 }
#define WM_GETTEXTLENGTH
Definition: winuser.h:1601
#define IDC_GROUP_NEW_DESCRIPTION
Definition: resource.h:80
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define EM_SETLIMITTEXT
Definition: winuser.h:1993
_In_ DWORD nLength
Definition: wincon.h:476
LPWSTR lgrpi1_comment
Definition: lmaccess.h:510
HWND WINAPI SetFocus(_In_opt_ HWND)
#define SendDlgItemMessage
Definition: winuser.h:5817
int32_t INT
Definition: typedefs.h:57
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
struct _LOCALGROUP_INFO_1 * PLOCALGROUP_INFO_1
#define GetDlgItemText
Definition: winuser.h:5760
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EM_SETSEL
Definition: winuser.h:2000
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
LPWSTR lgrpi1_name
Definition: lmaccess.h:509
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
BOOL CheckAccountName(HWND hwndDlg, INT nIdDlgItem, LPTSTR lpAccountName)
Definition: misc.c:27
#define HIWORD(l)
Definition: typedefs.h:246
#define IDC_GROUP_NEW_NAME
Definition: resource.h:79
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by GroupNew().

◆ OnGroupsPageBeginLabelEdit()

static BOOL OnGroupsPageBeginLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 322 of file groups.c.

323 {
324  HWND hwndEdit;
325 
326  hwndEdit = ListView_GetEditControl(pnmv->hdr.hwndFrom);
327  if (hwndEdit == NULL)
328  return TRUE;
329 
331 
332  return FALSE;
333 }
#define TRUE
Definition: types.h:120
#define EM_SETLIMITTEXT
Definition: winuser.h:1993
#define ListView_GetEditControl(hwndLV)
Definition: commctrl.h:2539
smooth NULL
Definition: ftsmooth.c:416
HWND hwndEdit
Definition: combotst.c:65
#define SendMessage
Definition: winuser.h:5818

Referenced by OnGroupsPageNotify().

◆ OnGroupsPageEndLabelEdit()

static BOOL OnGroupsPageEndLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 337 of file groups.c.

338 {
339  TCHAR szOldGroupName[UNLEN];
340  TCHAR szNewGroupName[UNLEN];
341  LOCALGROUP_INFO_0 lgrpi0;
343 
344  /* Leave, if there is no valid listview item */
345  if (pnmv->item.iItem == -1)
346  return FALSE;
347 
348  /* Get the new user name */
349  ListView_GetItemText(pnmv->hdr.hwndFrom,
350  pnmv->item.iItem, 0,
351  szOldGroupName,
352  UNLEN);
353 
354  /* Leave, if the user canceled the edit action */
355  if (pnmv->item.pszText == NULL)
356  return FALSE;
357 
358  /* Get the new user name */
359  lstrcpy(szNewGroupName, pnmv->item.pszText);
360 
361  /* Leave, if the user name was not changed */
362  if (lstrcmp(szOldGroupName, szNewGroupName) == 0)
363  return FALSE;
364 
365  /* Check the group name for illegal characters */
366  if (!CheckAccountName(NULL, 0, szNewGroupName))
367  return FALSE;
368 
369  /* Change the user name */
370  lgrpi0.lgrpi0_name = szNewGroupName;
371 
372  status = NetLocalGroupSetInfo(NULL, szOldGroupName, 0, (LPBYTE)&lgrpi0, NULL);
373  if (status != NERR_Success)
374  {
375  TCHAR szText[256];
376  wsprintf(szText, TEXT("Error: %u"), status);
377  MessageBox(NULL, szText, TEXT("NetLocalGroupSetInfo"), MB_ICONERROR | MB_OK);
378  return FALSE;
379  }
380 
381  /* Update the listview item */
382  ListView_SetItemText(pnmv->hdr.hwndFrom,
383  pnmv->item.iItem, 0,
384  szNewGroupName);
385 
386  return TRUE;
387 }
#define TRUE
Definition: types.h:120
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2680
#define NERR_Success
Definition: lmerr.h:5
NET_API_STATUS WINAPI NetLocalGroupSetInfo(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: local_group.c:1732
unsigned char * LPBYTE
Definition: typedefs.h:53
static const WCHAR szText[]
Definition: dialog.c:139
smooth NULL
Definition: ftsmooth.c:416
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2687
char TCHAR
Definition: xmlstorage.h:189
LPWSTR lgrpi0_name
Definition: lmaccess.h:506
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5797
#define lstrcmp
Definition: winbase.h:3712
#define TEXT(s)
Definition: k32.h:26
#define lstrcpy
Definition: winbase.h:3714
#define UNLEN
Definition: sspi.c:28
#define MB_OK
Definition: winuser.h:784
BOOL CheckAccountName(HWND hwndDlg, INT nIdDlgItem, LPTSTR lpAccountName)
Definition: misc.c:27
#define wsprintf
Definition: winuser.h:5840
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by OnGroupsPageNotify().

◆ OnGroupsPageInitDialog()

static VOID OnGroupsPageInitDialog ( HWND  hwndDlg)
static

Definition at line 297 of file groups.c.

298 {
300  HIMAGELIST hImgList;
301  HICON hIcon;
302 
303  /* Create the image list */
304  hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
306  ImageList_AddIcon(hImgList, hIcon);
308 
310 
312 
314 
316 
318 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDI_GROUP
Definition: resource.h:8
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:49
#define LVSIL_SMALL
Definition: commctrl.h:2295
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
static VOID UpdateGroupsList(HWND hwndListView)
Definition: groups.c:48
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2730
HINSTANCE hApplet
Definition: access.c:17
#define ILC_COLOR32
Definition: commctrl.h:354
static VOID SetGroupsListColumns(HWND hwndListView)
Definition: groups.c:22
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
HWND hwndListView
Definition: eventvwr.c:83
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2300
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2721
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
#define VOID
Definition: acefi.h:82
#define ILC_MASK
Definition: commctrl.h:347
HICON hIcon
Definition: msconfig.c:44
#define LoadImage
Definition: winuser.h:5790
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
#define IDC_GROUPS_LIST
Definition: resource.h:16

Referenced by GroupsPageProc().

◆ OnGroupsPageNotify()

static BOOL OnGroupsPageNotify ( HWND  hwndDlg,
PGROUP_DATA  pGroupData,
NMHDR phdr 
)
static

Definition at line 391 of file groups.c.

392 {
393  LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)phdr;
394 
395  switch (phdr->idFrom)
396  {
397  case IDC_GROUPS_LIST:
398  switch(phdr->code)
399  {
400  case NM_CLICK:
401  pGroupData->iCurrentItem = lpnmlv->iItem;
402  break;
403 
404  case NM_DBLCLK:
405  if (lpnmlv->iItem != -1)
406  {
407  UINT uItem;
408 
409  uItem = GetMenuDefaultItem(GetSubMenu(pGroupData->hPopupMenu, 1),
410  FALSE, 0);
411  if (uItem != (UINT)-1)
412  SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(uItem, 0), 0);
413  }
414  break;
415 
416  case NM_RCLICK:
417  ClientToScreen(GetDlgItem(hwndDlg, IDC_GROUPS_LIST), &lpnmlv->ptAction);
418  TrackPopupMenu(GetSubMenu(pGroupData->hPopupMenu, (lpnmlv->iItem == -1) ? 0 : 1),
419  TPM_LEFTALIGN, lpnmlv->ptAction.x, lpnmlv->ptAction.y, 0, hwndDlg, NULL);
420  break;
421 
422  case LVN_BEGINLABELEDIT:
424 
425  case LVN_ENDLABELEDIT:
427  }
428  break;
429  }
430 
431  return FALSE;
432 }
#define LVN_BEGINLABELEDIT
Definition: commctrl.h:3154
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
long y
Definition: polytest.cpp:48
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
long x
Definition: polytest.cpp:48
#define TPM_LEFTALIGN
Definition: winuser.h:2352
UINT code
Definition: winuser.h:3134
UINT_PTR idFrom
Definition: winuser.h:3133
static BOOL OnGroupsPageBeginLabelEdit(LPNMLVDISPINFO pnmv)
Definition: groups.c:322
HMENU hPopupMenu
Definition: groups.c:14
smooth NULL
Definition: ftsmooth.c:416
INT iCurrentItem
Definition: groups.c:16
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LPNMLVDISPINFO
Definition: commctrl.h:77
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
#define NM_CLICK
Definition: commctrl.h:130
#define NM_DBLCLK
Definition: commctrl.h:131
struct tagNMLISTVIEW * LPNMLISTVIEW
POINT ptAction
Definition: commctrl.h:3035
#define NM_RCLICK
Definition: commctrl.h:133
static BOOL OnGroupsPageEndLabelEdit(LPNMLVDISPINFO pnmv)
Definition: groups.c:337
unsigned int UINT
Definition: ndis.h:50
#define SendMessage
Definition: winuser.h:5818
UINT WINAPI GetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define LVN_ENDLABELEDIT
Definition: commctrl.h:3155
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define IDC_GROUPS_LIST
Definition: resource.h:16

Referenced by GroupsPageProc().

◆ SetGroupsListColumns()

static VOID SetGroupsListColumns ( HWND  hwndListView)
static

Definition at line 22 of file groups.c.

23 {
25  RECT rect;
26  TCHAR szStr[32];
27 
29 
30  memset(&column, 0x00, sizeof(column));
32  column.fmt = LVCFMT_LEFT;
33  column.cx = (INT)((rect.right - rect.left) * 0.40);
34  column.iSubItem = 0;
35  LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
36  column.pszText = szStr;
38 
39  column.cx = (INT)((rect.right - rect.left) * 0.60);
40  column.iSubItem = 1;
41  LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
42  column.pszText = szStr;
44 }
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
#define LVCF_TEXT
Definition: commctrl.h:2584
#define LV_COLUMN
Definition: commctrl.h:2543
#define IDS_DESCRIPTION
Definition: resource.h:92
#define INT
Definition: polytest.cpp:20
#define LVCFMT_LEFT
Definition: commctrl.h:2594
HINSTANCE hApplet
Definition: access.c:17
& rect
Definition: startmenu.cpp:1413
#define LVCF_SUBITEM
Definition: commctrl.h:2585
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2632
HWND hwndListView
Definition: eventvwr.c:83
char TCHAR
Definition: xmlstorage.h:189
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define LVCF_FMT
Definition: commctrl.h:2582
#define IDS_NAME
Definition: resource.h:90
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
#define memset(x, y, z)
Definition: compat.h:39
#define LoadString
Definition: winuser.h:5794

Referenced by OnGroupsPageInitDialog().

◆ UpdateGroupProperties()

static VOID UpdateGroupProperties ( HWND  hwndDlg)
static

Definition at line 91 of file groups.c.

92 {
93  TCHAR szGroupName[UNLEN];
94  INT iItem;
95  HWND hwndLV;
96  PLOCALGROUP_INFO_1 pGroupInfo = NULL;
97 
98  hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
99  iItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
100  if (iItem == -1)
101  return;
102 
103  /* Get the group name */
104  ListView_GetItemText(hwndLV,
105  iItem, 0,
106  szGroupName,
107  UNLEN);
108 
109  NetLocalGroupGetInfo(NULL, szGroupName, 1, (LPBYTE*)&pGroupInfo);
110 
111  ListView_SetItemText(hwndLV, iItem, 1,
112  pGroupInfo->lgrpi1_comment);
113 
114  NetApiBufferFree(pGroupInfo);
115 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2430
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2680
LPWSTR lgrpi1_comment
Definition: lmaccess.h:510
#define LVNI_SELECTED
Definition: commctrl.h:2420
int32_t INT
Definition: typedefs.h:57
unsigned char * LPBYTE
Definition: typedefs.h:53
NET_API_STATUS WINAPI NetLocalGroupGetInfo(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE *bufptr)
Definition: local_group.c:1225
smooth NULL
Definition: ftsmooth.c:416
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2687
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define UNLEN
Definition: sspi.c:28
#define IDC_GROUPS_LIST
Definition: resource.h:16

Referenced by GroupsPageProc().

◆ UpdateGroupsList()

static VOID UpdateGroupsList ( HWND  hwndListView)
static

Definition at line 48 of file groups.c.

49 {
50  NET_API_STATUS netStatus;
52  DWORD entriesread;
53  DWORD totalentries;
54  DWORD_PTR resume_handle = 0;
55  DWORD i;
56  LV_ITEM lvi;
57  INT iItem;
58 
59  for (;;)
60  {
61  netStatus = NetLocalGroupEnum(NULL, 1, (LPBYTE*)&pBuffer,
62  1024, &entriesread,
63  &totalentries, &resume_handle);
64  if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
65  break;
66 
67  for (i = 0; i < entriesread; i++)
68  {
69  memset(&lvi, 0x00, sizeof(lvi));
70  lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
71  lvi.pszText = pBuffer[i].lgrpi1_name;
72  lvi.state = 0;
73  lvi.iImage = 0;
74  iItem = ListView_InsertItem(hwndListView, &lvi);
75 
77  pBuffer[i].lgrpi1_comment);
78  }
79 
81 
82  /* No more data left */
83  if (netStatus != ERROR_MORE_DATA)
84  break;
85  }
86 
87 }
#define LV_ITEM
Definition: commctrl.h:2333
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
int32_t INT
Definition: typedefs.h:57
#define NERR_Success
Definition: lmerr.h:5
#define LVIF_TEXT
Definition: commctrl.h:2305
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
unsigned char * LPBYTE
Definition: typedefs.h:53
HWND hwndListView
Definition: eventvwr.c:83
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2687
#define LVIF_IMAGE
Definition: commctrl.h:2306
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:64
#define ERROR_MORE_DATA
Definition: dderror.h:13
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetLocalGroupEnum(LPCWSTR servername, DWORD level, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries, PDWORD_PTR resumehandle)
Definition: local_group.c:974
#define LVIF_STATE
Definition: commctrl.h:2308
#define memset(x, y, z)
Definition: compat.h:39

Referenced by OnGroupsPageInitDialog().