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.

330 lines
9.7 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 = { 0x96713509, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
  22. // {96713509-6BE7-11d3-9156-00C04F65B3F9}
  23. //DEFINE_GUID(<<name>>,
  24. //0x96713509, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
  25. const GUID CBicycleFolder::thisGuid = { 0x9671350a, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
  26. // {9671350A-6BE7-11d3-9156-00C04F65B3F9}
  27. //DEFINE_GUID(<<name>>,
  28. //0x9671350a, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
  29. const GUID CSkateboardFolder::thisGuid = { 0x9671350b, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
  30. // {9671350B-6BE7-11d3-9156-00C04F65B3F9}
  31. //DEFINE_GUID(<<name>>,
  32. //0x9671350b, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
  33. const GUID CIceSkateFolder::thisGuid = { 0x9e3ff365, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
  34. // {9E3FF365-6BE7-11d3-9156-00C04F65B3F9}
  35. //DEFINE_GUID(<<name>>,
  36. //0x9e3ff365, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
  37. const GUID CBicycle::thisGuid = { 0x9e3ff366, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
  38. // {9E3FF366-6BE7-11d3-9156-00C04F65B3F9}
  39. //DEFINE_GUID(<<name>>,
  40. //0x9e3ff366, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
  41. const GUID CSkateboard::thisGuid = { 0xa6707e01, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
  42. // {A6707E01-6BE7-11d3-9156-00C04F65B3F9}
  43. //DEFINE_GUID(<<name>>,
  44. //0xa6707e01, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
  45. const GUID CIceSkate::thisGuid = { 0xa6707e02, 0x6be7, 0x11d3, {0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9} };
  46. // {A6707E02-6BE7-11d3-9156-00C04F65B3F9}
  47. //DEFINE_GUID(<<name>>,
  48. //0xa6707e02, 0x6be7, 0x11d3, 0x91, 0x56, 0x0, 0xc0, 0x4f, 0x65, 0xb3, 0xf9);
  49. //==============================================================
  50. //
  51. // CPeoplePoweredVehicle implementation
  52. //
  53. //
  54. CPeoplePoweredVehicle::CPeoplePoweredVehicle()
  55. {
  56. children[0] = new CBicycleFolder;
  57. children[1] = new CSkateboardFolder;
  58. children[2] = new CIceSkateFolder;
  59. }
  60. CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
  61. {
  62. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  63. delete children[n];
  64. }
  65. HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
  66. {
  67. SCOPEDATAITEM sdi;
  68. if (!bExpanded) {
  69. // create the child nodes, then expand them
  70. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  71. ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
  72. sdi.mask = SDI_STR | // Displayname is valid
  73. SDI_PARAM | // lParam is valid
  74. SDI_IMAGE | // nImage is valid
  75. SDI_OPENIMAGE | // nOpenImage is valid
  76. SDI_PARENT | // relativeID is valid
  77. SDI_CHILDREN; // cChildren is valid
  78. sdi.relativeID = (HSCOPEITEM)parent;
  79. sdi.nImage = children[n]->GetBitmapIndex();
  80. sdi.nOpenImage = INDEX_OPENFOLDER;
  81. sdi.displayname = MMC_CALLBACK;
  82. sdi.lParam = (LPARAM)children[n]; // The cookie
  83. sdi.cChildren = 0;
  84. HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
  85. _ASSERT( SUCCEEDED(hr) );
  86. children[n]->SetScopeItemValue(sdi.ID);
  87. }
  88. }
  89. return S_OK;
  90. }
  91. CBicycleFolder::CBicycleFolder()
  92. {
  93. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  94. children[n] = new CBicycle(n + 1);
  95. }
  96. }
  97. CBicycleFolder::~CBicycleFolder()
  98. {
  99. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  100. if (children[n]) {
  101. delete children[n];
  102. }
  103. }
  104. HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  105. {
  106. HRESULT hr = S_OK;
  107. IHeaderCtrl *pHeaderCtrl = NULL;
  108. IResultData *pResultData = NULL;
  109. if (bShow) {
  110. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  111. _ASSERT( SUCCEEDED(hr) );
  112. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  113. _ASSERT( SUCCEEDED(hr) );
  114. // Set the column headers in the results pane
  115. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  116. _ASSERT( S_OK == hr );
  117. // insert items here
  118. RESULTDATAITEM rdi;
  119. hr = pResultData->DeleteAllRsltItems();
  120. _ASSERT( SUCCEEDED(hr) );
  121. if (!bExpanded) {
  122. // create the child nodes, then expand them
  123. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  124. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  125. rdi.mask = RDI_STR | // Displayname is valid
  126. RDI_IMAGE |
  127. RDI_PARAM; // nImage is valid
  128. rdi.nImage = children[n]->GetBitmapIndex();
  129. rdi.str = MMC_CALLBACK;
  130. rdi.nCol = 0;
  131. rdi.lParam = (LPARAM)children[n];
  132. hr = pResultData->InsertItem( &rdi );
  133. _ASSERT( SUCCEEDED(hr) );
  134. }
  135. }
  136. pHeaderCtrl->Release();
  137. pResultData->Release();
  138. }
  139. return hr;
  140. }
  141. CIceSkateFolder::CIceSkateFolder()
  142. {
  143. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  144. children[n] = new CIceSkate(n + 1);
  145. }
  146. }
  147. CIceSkateFolder::~CIceSkateFolder()
  148. {
  149. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  150. if (children[n]) {
  151. delete children[n];
  152. }
  153. }
  154. HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  155. {
  156. HRESULT hr = S_OK;
  157. IHeaderCtrl *pHeaderCtrl = NULL;
  158. IResultData *pResultData = NULL;
  159. if (bShow) {
  160. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  161. _ASSERT( SUCCEEDED(hr) );
  162. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  163. _ASSERT( SUCCEEDED(hr) );
  164. // Set the column headers in the results pane
  165. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  166. _ASSERT( S_OK == hr );
  167. // insert items here
  168. RESULTDATAITEM rdi;
  169. hr = pResultData->DeleteAllRsltItems();
  170. _ASSERT( SUCCEEDED(hr) );
  171. if (!bExpanded) {
  172. // create the child nodes, then expand them
  173. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  174. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  175. rdi.mask = RDI_STR | // Displayname is valid
  176. RDI_IMAGE |
  177. RDI_PARAM; // nImage is valid
  178. rdi.nImage = children[n]->GetBitmapIndex();
  179. rdi.str = MMC_CALLBACK;
  180. rdi.nCol = 0;
  181. rdi.lParam = (LPARAM)children[n];
  182. hr = pResultData->InsertItem( &rdi );
  183. _ASSERT( SUCCEEDED(hr) );
  184. }
  185. }
  186. pHeaderCtrl->Release();
  187. pResultData->Release();
  188. }
  189. return hr;
  190. }
  191. CSkateboardFolder::CSkateboardFolder()
  192. {
  193. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  194. children[n] = new CSkateboard(n + 1);
  195. }
  196. }
  197. CSkateboardFolder::~CSkateboardFolder()
  198. {
  199. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  200. if (children[n]) {
  201. delete children[n];
  202. }
  203. }
  204. HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  205. {
  206. HRESULT hr = S_OK;
  207. IHeaderCtrl *pHeaderCtrl = NULL;
  208. IResultData *pResultData = NULL;
  209. if (bShow) {
  210. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  211. _ASSERT( SUCCEEDED(hr) );
  212. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  213. _ASSERT( SUCCEEDED(hr) );
  214. // Set the column headers in the results pane
  215. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  216. _ASSERT( S_OK == hr );
  217. // insert items here
  218. RESULTDATAITEM rdi;
  219. hr = pResultData->DeleteAllRsltItems();
  220. _ASSERT( SUCCEEDED(hr) );
  221. if (!bExpanded) {
  222. // create the child nodes, then expand them
  223. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  224. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  225. rdi.mask = RDI_STR | // Displayname is valid
  226. RDI_IMAGE |
  227. RDI_PARAM; // nImage is valid
  228. rdi.nImage = children[n]->GetBitmapIndex();
  229. rdi.str = MMC_CALLBACK;
  230. rdi.nCol = 0;
  231. rdi.lParam = (LPARAM)children[n];
  232. hr = pResultData->InsertItem( &rdi );
  233. _ASSERT( SUCCEEDED(hr) );
  234. }
  235. }
  236. pHeaderCtrl->Release();
  237. pResultData->Release();
  238. }
  239. return hr;
  240. }
  241. const _TCHAR *CBicycle::GetDisplayName(int nCol)
  242. {
  243. static _TCHAR buf[128];
  244. _stprintf(buf, _T("Bicycle #%d"), id);
  245. return buf;
  246. }
  247. const _TCHAR *CSkateboard::GetDisplayName(int nCol)
  248. {
  249. static _TCHAR buf[128];
  250. _stprintf(buf, _T("Skateboard #%d"), id);
  251. return buf;
  252. }
  253. const _TCHAR *CIceSkate::GetDisplayName(int nCol)
  254. {
  255. static _TCHAR buf[128];
  256. _stprintf(buf, _T("Ice Skate #%d"), id);
  257. return buf;
  258. }