Leaked source code of windows server 2003
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.

99 lines
2.9 KiB

  1. //==============================================================;
  2. //
  3. // This source code is only intended as a supplement to
  4. // existing Microsoft documentation.
  5. //
  6. //
  7. //
  8. //
  9. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  10. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  11. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  12. // PURPOSE.
  13. //
  14. // Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  15. //
  16. //
  17. //
  18. //==============================================================;
  19. #include "StatNode.h"
  20. #include "Space.h"
  21. #include "Sky.h"
  22. #include "People.h"
  23. #include "Land.h"
  24. const GUID CStaticNode::thisGuid = { 0x2974380c, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
  25. //==============================================================
  26. //
  27. // CStaticNode implementation
  28. //
  29. //
  30. CStaticNode::CStaticNode()
  31. {
  32. children[0] = new CPeoplePoweredVehicle;
  33. children[1] = new CLandBasedVehicle;
  34. children[2] = new CSkyBasedVehicle;
  35. children[3] = new CSpaceVehicle;
  36. }
  37. CStaticNode::~CStaticNode()
  38. {
  39. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  40. if (children[n]) {
  41. delete children[n];
  42. }
  43. }
  44. HRESULT CStaticNode::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
  45. {
  46. SCOPEDATAITEM sdi;
  47. if (!bExpanded) {
  48. // create the child nodes, then expand them
  49. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  50. ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
  51. sdi.mask = SDI_STR | // Displayname is valid
  52. SDI_PARAM | // lParam is valid
  53. SDI_IMAGE | // nImage is valid
  54. SDI_OPENIMAGE | // nOpenImage is valid
  55. SDI_PARENT |
  56. SDI_CHILDREN;
  57. sdi.relativeID = (HSCOPEITEM)parent;
  58. sdi.nImage = children[n]->GetBitmapIndex();
  59. sdi.nOpenImage = INDEX_OPENFOLDER;
  60. sdi.displayname = MMC_CALLBACK;
  61. sdi.lParam = (LPARAM)children[n]; // The cookie
  62. sdi.cChildren = (n == 0); // only the first child has children
  63. HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
  64. _ASSERT( SUCCEEDED(hr) );
  65. }
  66. bExpanded = TRUE;
  67. }
  68. return S_OK;
  69. }
  70. HRESULT CStaticNode::OnShowContextHelp(IDisplayHelp *m_ipDisplayHelp, LPOLESTR helpFile)
  71. {
  72. WCHAR topicName[MAX_PATH];
  73. wcscpy(topicName, helpFile);
  74. // we should read this from a resource file
  75. wcscat(topicName, L"::/default.htm");
  76. LPOLESTR pszTopic = static_cast<LPOLESTR>(CoTaskMemAlloc((wcslen(topicName) + 1) * sizeof(WCHAR)));
  77. wcscpy(pszTopic, topicName);
  78. return m_ipDisplayHelp->ShowTopic(pszTopic);
  79. }