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.

66 lines
1.6 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright 1995 - 1997 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. #include "stdafx.h"
  9. #include "Service.h"
  10. #include "CSnapin.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. void CFolder::Create(LPWSTR szName, int nImage, int nOpenImage,
  17. FOLDER_TYPES type, BOOL bHasChildren)
  18. {
  19. ASSERT(m_pScopeItem == NULL); // Calling create twice on this item?
  20. // Two-stage construction
  21. m_pScopeItem = new SCOPEDATAITEM;
  22. memset(m_pScopeItem, 0, sizeof(SCOPEDATAITEM));
  23. // Set folder type
  24. m_type = type;
  25. // Add node name
  26. if (szName != NULL)
  27. {
  28. m_pScopeItem->mask = SDI_STR;
  29. m_pScopeItem->displayname = (unsigned short*)(-1);
  30. UINT uiByteLen = (wcslen(szName) + 1) * sizeof(OLECHAR);
  31. LPOLESTR psz = (LPOLESTR)::CoTaskMemAlloc(uiByteLen);
  32. if (psz != NULL)
  33. {
  34. wcscpy(psz, szName);
  35. m_pszName = psz;
  36. }
  37. }
  38. // Add close image
  39. if (nImage != 0)
  40. {
  41. m_pScopeItem->mask |= SDI_IMAGE;
  42. m_pScopeItem->nImage = nImage;
  43. }
  44. // Add open image
  45. if (nOpenImage != 0)
  46. {
  47. m_pScopeItem->mask |= SDI_OPENIMAGE;
  48. m_pScopeItem->nOpenImage = nOpenImage;
  49. }
  50. // Add button to node if the folder has children
  51. m_pScopeItem->mask |= SDI_CHILDREN;
  52. m_pScopeItem->cChildren = (bHasChildren == TRUE) ? 1 : 0;
  53. }