Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.2 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. #include "admincfg.h"
  6. BOOL OnRemove(HWND hwndApp,HWND hwndList)
  7. {
  8. int nItem,nItemStart=-1;
  9. UINT nSelItems=0;
  10. BOOL fRet=TRUE;
  11. // find out how many items are selected
  12. while ((nItem=ListView_GetNextItem(hwndList,nItemStart,LVNI_SELECTED))
  13. >=0) {
  14. nSelItems++;
  15. nItemStart = nItem;
  16. }
  17. if (!nSelItems) return FALSE; // nothing selected
  18. // display appropriate message depending on whether 1 user, 1 workstation,
  19. // 1 group or multiple items selected
  20. if (nSelItems == 1) {
  21. HGLOBAL hUser;
  22. USERDATA *pUserData;
  23. UINT uMsg;
  24. int nRet;
  25. if (!(hUser = (HGLOBAL) LongToHandle(ListView_GetItemParm(hwndList,nItemStart))) ||
  26. !(pUserData = (USERDATA *) GlobalLock(hUser)))
  27. return FALSE;
  28. switch (pUserData->hdr.dwType) {
  29. #ifdef INCL_GROUP_SUPPORT
  30. case (UT_USER | UF_GROUP):
  31. uMsg = IDS_QUERYREMOVE_GROUP;
  32. break;
  33. #endif
  34. case UT_USER:
  35. uMsg = IDS_QUERYREMOVE_USER;
  36. break;
  37. default:
  38. uMsg = IDS_QUERYREMOVE_WORKSTA;
  39. break;
  40. }
  41. nRet=MsgBoxParam(hwndApp,uMsg,pUserData->hdr.szName,MB_ICONQUESTION,
  42. MB_YESNO);
  43. GlobalUnlock(hUser);
  44. if (nRet != IDYES)
  45. return FALSE;
  46. } else {
  47. if (MsgBox(hwndApp,IDS_QUERYREMOVE_MULTIPLE,MB_ICONQUESTION,MB_YESNO)
  48. != IDYES)
  49. return FALSE;
  50. }
  51. // remove all selected items
  52. while (((nItem=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED))
  53. >=0) && fRet) {
  54. #ifdef INCL_GROUP_SUPPORT
  55. HGLOBAL hUser;
  56. USERDATA *pUserData;
  57. if ((hUser = (HGLOBAL) LongToHandle(ListView_GetItemParm(hwndList,nItem))) &&
  58. (pUserData = (USERDATA *) GlobalLock(hUser))) {
  59. if (pUserData->hdr.dwType == (UT_USER | UF_GROUP))
  60. RemoveGroupPriEntry(pUserData->hdr.szName);
  61. GlobalUnlock(hUser);
  62. }
  63. #endif
  64. fRet=RemoveUser(hwndList,nItem,TRUE);
  65. }
  66. if (fRet) {
  67. dwAppState |= AS_FILEDIRTY; // file is dirty
  68. dwAppState &= ~AS_CANREMOVE; // no selection in list ctrl, disable item
  69. EnableMenuItems(hwndApp,dwAppState);
  70. SetStatusItemCount(hwndList);
  71. }
  72. return fRet;
  73. }