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.

310 lines
9.3 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 <stdio.h>
  20. #include "People.h"
  21. const GUID CPeoplePoweredVehicle::thisGuid = { 0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
  22. const GUID CBicycleFolder::thisGuid = { 0xef163732, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  23. const GUID CSkateboardFolder::thisGuid = { 0xef163733, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  24. const GUID CIceSkateFolder::thisGuid = { 0xf6c660b0, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  25. const GUID CBicycle::thisGuid = { 0xef163734, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  26. const GUID CSkateboard::thisGuid = { 0xef163735, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  27. const GUID CIceSkate::thisGuid = { 0xf6c660b1, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  28. //==============================================================
  29. //
  30. // CPeoplePoweredVehicle implementation
  31. //
  32. //
  33. CPeoplePoweredVehicle::CPeoplePoweredVehicle()
  34. {
  35. children[0] = new CBicycleFolder;
  36. children[1] = new CSkateboardFolder;
  37. children[2] = new CIceSkateFolder;
  38. }
  39. CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
  40. {
  41. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  42. delete children[n];
  43. }
  44. HRESULT CPeoplePoweredVehicle::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 | // relativeID is valid
  56. SDI_CHILDREN; // cChildren is valid
  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 = 0;
  63. HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
  64. children[n]->SetHandle((HANDLE)sdi.ID);
  65. _ASSERT( SUCCEEDED(hr) );
  66. }
  67. }
  68. return S_OK;
  69. }
  70. CBicycleFolder::CBicycleFolder()
  71. {
  72. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  73. children[n] = new CBicycle(n + 1);
  74. }
  75. }
  76. CBicycleFolder::~CBicycleFolder()
  77. {
  78. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  79. if (children[n]) {
  80. delete children[n];
  81. }
  82. }
  83. HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  84. {
  85. HRESULT hr = S_OK;
  86. IHeaderCtrl *pHeaderCtrl = NULL;
  87. IResultData *pResultData = NULL;
  88. if (bShow) {
  89. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  90. _ASSERT( SUCCEEDED(hr) );
  91. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  92. _ASSERT( SUCCEEDED(hr) );
  93. // Set the column headers in the results pane
  94. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  95. _ASSERT( S_OK == hr );
  96. // insert items here
  97. RESULTDATAITEM rdi;
  98. hr = pResultData->DeleteAllRsltItems();
  99. _ASSERT( SUCCEEDED(hr) );
  100. if (!bExpanded) {
  101. // create the child nodes, then expand them
  102. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  103. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  104. rdi.mask = RDI_STR | // Displayname is valid
  105. RDI_IMAGE |
  106. RDI_PARAM; // nImage is valid
  107. rdi.nImage = children[n]->GetBitmapIndex();
  108. rdi.str = MMC_CALLBACK;
  109. rdi.nCol = 0;
  110. rdi.lParam = (LPARAM)children[n];
  111. hr = pResultData->InsertItem( &rdi );
  112. children[n]->SetHandle((HANDLE)rdi.itemID);
  113. _ASSERT( SUCCEEDED(hr) );
  114. }
  115. }
  116. pHeaderCtrl->Release();
  117. pResultData->Release();
  118. }
  119. return hr;
  120. }
  121. CIceSkateFolder::CIceSkateFolder()
  122. {
  123. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  124. children[n] = new CIceSkate(n + 1);
  125. }
  126. }
  127. CIceSkateFolder::~CIceSkateFolder()
  128. {
  129. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  130. if (children[n]) {
  131. delete children[n];
  132. }
  133. }
  134. HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  135. {
  136. HRESULT hr = S_OK;
  137. IHeaderCtrl *pHeaderCtrl = NULL;
  138. IResultData *pResultData = NULL;
  139. if (bShow) {
  140. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  141. _ASSERT( SUCCEEDED(hr) );
  142. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  143. _ASSERT( SUCCEEDED(hr) );
  144. // Set the column headers in the results pane
  145. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  146. _ASSERT( S_OK == hr );
  147. // insert items here
  148. RESULTDATAITEM rdi;
  149. hr = pResultData->DeleteAllRsltItems();
  150. _ASSERT( SUCCEEDED(hr) );
  151. if (!bExpanded) {
  152. // create the child nodes, then expand them
  153. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  154. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  155. rdi.mask = RDI_STR | // Displayname is valid
  156. RDI_IMAGE |
  157. RDI_PARAM; // nImage is valid
  158. rdi.nImage = children[n]->GetBitmapIndex();
  159. rdi.str = MMC_CALLBACK;
  160. rdi.nCol = 0;
  161. rdi.lParam = (LPARAM)children[n];
  162. hr = pResultData->InsertItem( &rdi );
  163. children[n]->SetHandle((HANDLE)rdi.itemID);
  164. _ASSERT( SUCCEEDED(hr) );
  165. }
  166. }
  167. pHeaderCtrl->Release();
  168. pResultData->Release();
  169. }
  170. return hr;
  171. }
  172. CSkateboardFolder::CSkateboardFolder()
  173. {
  174. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  175. children[n] = new CSkateboard(n + 1);
  176. }
  177. }
  178. CSkateboardFolder::~CSkateboardFolder()
  179. {
  180. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  181. if (children[n]) {
  182. delete children[n];
  183. }
  184. }
  185. HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  186. {
  187. HRESULT hr = S_OK;
  188. IHeaderCtrl *pHeaderCtrl = NULL;
  189. IResultData *pResultData = NULL;
  190. if (bShow) {
  191. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  192. _ASSERT( SUCCEEDED(hr) );
  193. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  194. _ASSERT( SUCCEEDED(hr) );
  195. // Set the column headers in the results pane
  196. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  197. _ASSERT( S_OK == hr );
  198. // insert items here
  199. RESULTDATAITEM rdi;
  200. hr = pResultData->DeleteAllRsltItems();
  201. _ASSERT( SUCCEEDED(hr) );
  202. if (!bExpanded) {
  203. // create the child nodes, then expand them
  204. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  205. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  206. rdi.mask = RDI_STR | // Displayname is valid
  207. RDI_IMAGE |
  208. RDI_PARAM; // nImage is valid
  209. rdi.nImage = children[n]->GetBitmapIndex();
  210. rdi.str = MMC_CALLBACK;
  211. rdi.nCol = 0;
  212. rdi.lParam = (LPARAM)children[n];
  213. hr = pResultData->InsertItem( &rdi );
  214. children[n]->SetHandle((HANDLE)rdi.itemID);
  215. _ASSERT( SUCCEEDED(hr) );
  216. }
  217. }
  218. pHeaderCtrl->Release();
  219. pResultData->Release();
  220. }
  221. return hr;
  222. }
  223. const _TCHAR *CBicycle::GetDisplayName(int nCol)
  224. {
  225. static _TCHAR buf[128];
  226. _stprintf(buf, _T("Bicycle #%d"), id);
  227. return buf;
  228. }
  229. const _TCHAR *CSkateboard::GetDisplayName(int nCol)
  230. {
  231. static _TCHAR buf[128];
  232. _stprintf(buf, _T("Skateboard #%d"), id);
  233. return buf;
  234. }
  235. const _TCHAR *CIceSkate::GetDisplayName(int nCol)
  236. {
  237. static _TCHAR buf[128];
  238. _stprintf(buf, _T("Ice Skate #%d"), id);
  239. return buf;
  240. }