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.

302 lines
9.0 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. _ASSERT( SUCCEEDED(hr) );
  65. }
  66. }
  67. return S_OK;
  68. }
  69. CBicycleFolder::CBicycleFolder()
  70. {
  71. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  72. children[n] = new CBicycle(n + 1);
  73. }
  74. }
  75. CBicycleFolder::~CBicycleFolder()
  76. {
  77. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  78. if (children[n]) {
  79. delete children[n];
  80. }
  81. }
  82. HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  83. {
  84. HRESULT hr = S_OK;
  85. IHeaderCtrl *pHeaderCtrl = NULL;
  86. IResultData *pResultData = NULL;
  87. if (bShow) {
  88. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  89. _ASSERT( SUCCEEDED(hr) );
  90. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  91. _ASSERT( SUCCEEDED(hr) );
  92. // Set the column headers in the results pane
  93. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  94. _ASSERT( S_OK == hr );
  95. // insert items here
  96. RESULTDATAITEM rdi;
  97. hr = pResultData->DeleteAllRsltItems();
  98. _ASSERT( SUCCEEDED(hr) );
  99. if (!bExpanded) {
  100. // create the child nodes, then expand them
  101. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  102. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  103. rdi.mask = RDI_STR | // Displayname is valid
  104. RDI_IMAGE |
  105. RDI_PARAM; // nImage is valid
  106. rdi.nImage = children[n]->GetBitmapIndex();
  107. rdi.str = MMC_CALLBACK;
  108. rdi.nCol = 0;
  109. rdi.lParam = (LPARAM)children[n];
  110. hr = pResultData->InsertItem( &rdi );
  111. _ASSERT( SUCCEEDED(hr) );
  112. }
  113. }
  114. pHeaderCtrl->Release();
  115. pResultData->Release();
  116. }
  117. return hr;
  118. }
  119. CIceSkateFolder::CIceSkateFolder()
  120. {
  121. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  122. children[n] = new CIceSkate(n + 1);
  123. }
  124. }
  125. CIceSkateFolder::~CIceSkateFolder()
  126. {
  127. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  128. if (children[n]) {
  129. delete children[n];
  130. }
  131. }
  132. HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  133. {
  134. HRESULT hr = S_OK;
  135. IHeaderCtrl *pHeaderCtrl = NULL;
  136. IResultData *pResultData = NULL;
  137. if (bShow) {
  138. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  139. _ASSERT( SUCCEEDED(hr) );
  140. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  141. _ASSERT( SUCCEEDED(hr) );
  142. // Set the column headers in the results pane
  143. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  144. _ASSERT( S_OK == hr );
  145. // insert items here
  146. RESULTDATAITEM rdi;
  147. hr = pResultData->DeleteAllRsltItems();
  148. _ASSERT( SUCCEEDED(hr) );
  149. if (!bExpanded) {
  150. // create the child nodes, then expand them
  151. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  152. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  153. rdi.mask = RDI_STR | // Displayname is valid
  154. RDI_IMAGE |
  155. RDI_PARAM; // nImage is valid
  156. rdi.nImage = children[n]->GetBitmapIndex();
  157. rdi.str = MMC_CALLBACK;
  158. rdi.nCol = 0;
  159. rdi.lParam = (LPARAM)children[n];
  160. hr = pResultData->InsertItem( &rdi );
  161. _ASSERT( SUCCEEDED(hr) );
  162. }
  163. }
  164. pHeaderCtrl->Release();
  165. pResultData->Release();
  166. }
  167. return hr;
  168. }
  169. CSkateboardFolder::CSkateboardFolder()
  170. {
  171. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  172. children[n] = new CSkateboard(n + 1);
  173. }
  174. }
  175. CSkateboardFolder::~CSkateboardFolder()
  176. {
  177. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  178. if (children[n]) {
  179. delete children[n];
  180. }
  181. }
  182. HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  183. {
  184. HRESULT hr = S_OK;
  185. IHeaderCtrl *pHeaderCtrl = NULL;
  186. IResultData *pResultData = NULL;
  187. if (bShow) {
  188. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  189. _ASSERT( SUCCEEDED(hr) );
  190. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  191. _ASSERT( SUCCEEDED(hr) );
  192. // Set the column headers in the results pane
  193. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  194. _ASSERT( S_OK == hr );
  195. // insert items here
  196. RESULTDATAITEM rdi;
  197. hr = pResultData->DeleteAllRsltItems();
  198. _ASSERT( SUCCEEDED(hr) );
  199. if (!bExpanded) {
  200. // create the child nodes, then expand them
  201. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  202. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  203. rdi.mask = RDI_STR | // Displayname is valid
  204. RDI_IMAGE |
  205. RDI_PARAM; // nImage is valid
  206. rdi.nImage = children[n]->GetBitmapIndex();
  207. rdi.str = MMC_CALLBACK;
  208. rdi.nCol = 0;
  209. rdi.lParam = (LPARAM)children[n];
  210. hr = pResultData->InsertItem( &rdi );
  211. _ASSERT( SUCCEEDED(hr) );
  212. }
  213. }
  214. pHeaderCtrl->Release();
  215. pResultData->Release();
  216. }
  217. return hr;
  218. }
  219. const _TCHAR *CBicycle::GetDisplayName(int nCol)
  220. {
  221. static _TCHAR buf[128];
  222. _stprintf(buf, _T("Bicycle #%d"), id);
  223. return buf;
  224. }
  225. const _TCHAR *CSkateboard::GetDisplayName(int nCol)
  226. {
  227. static _TCHAR buf[128];
  228. _stprintf(buf, _T("Skateboard #%d"), id);
  229. return buf;
  230. }
  231. const _TCHAR *CIceSkate::GetDisplayName(int nCol)
  232. {
  233. static _TCHAR buf[128];
  234. _stprintf(buf, _T("Ice Skate #%d"), id);
  235. return buf;
  236. }