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.

304 lines
9.1 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(CComponentData *pComponentData)
  34. {
  35. m_pComponentData = pComponentData;
  36. children[0] = new CBicycleFolder;
  37. children[1] = new CSkateboardFolder;
  38. children[2] = new CIceSkateFolder;
  39. }
  40. CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
  41. {
  42. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  43. delete children[n];
  44. }
  45. HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
  46. {
  47. SCOPEDATAITEM sdi;
  48. if (!bExpanded) {
  49. // create the child nodes, then expand them
  50. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  51. ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
  52. sdi.mask = SDI_STR | // Displayname is valid
  53. SDI_PARAM | // lParam is valid
  54. SDI_IMAGE | // nImage is valid
  55. SDI_OPENIMAGE | // nOpenImage is valid
  56. SDI_PARENT | // relativeID is valid
  57. SDI_CHILDREN; // cChildren is valid
  58. sdi.relativeID = (HSCOPEITEM)parent;
  59. sdi.nImage = children[n]->GetBitmapIndex();
  60. sdi.nOpenImage = INDEX_OPENFOLDER;
  61. sdi.displayname = MMC_CALLBACK;
  62. sdi.lParam = (LPARAM)children[n]; // The cookie
  63. sdi.cChildren = 0;
  64. HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
  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. _ASSERT( SUCCEEDED(hr) );
  113. }
  114. }
  115. pHeaderCtrl->Release();
  116. pResultData->Release();
  117. }
  118. return hr;
  119. }
  120. CIceSkateFolder::CIceSkateFolder()
  121. {
  122. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  123. children[n] = new CIceSkate(n + 1);
  124. }
  125. }
  126. CIceSkateFolder::~CIceSkateFolder()
  127. {
  128. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  129. if (children[n]) {
  130. delete children[n];
  131. }
  132. }
  133. HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  134. {
  135. HRESULT hr = S_OK;
  136. IHeaderCtrl *pHeaderCtrl = NULL;
  137. IResultData *pResultData = NULL;
  138. if (bShow) {
  139. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  140. _ASSERT( SUCCEEDED(hr) );
  141. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  142. _ASSERT( SUCCEEDED(hr) );
  143. // Set the column headers in the results pane
  144. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  145. _ASSERT( S_OK == hr );
  146. // insert items here
  147. RESULTDATAITEM rdi;
  148. hr = pResultData->DeleteAllRsltItems();
  149. _ASSERT( SUCCEEDED(hr) );
  150. if (!bExpanded) {
  151. // create the child nodes, then expand them
  152. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  153. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  154. rdi.mask = RDI_STR | // Displayname is valid
  155. RDI_IMAGE |
  156. RDI_PARAM; // nImage is valid
  157. rdi.nImage = children[n]->GetBitmapIndex();
  158. rdi.str = MMC_CALLBACK;
  159. rdi.nCol = 0;
  160. rdi.lParam = (LPARAM)children[n];
  161. hr = pResultData->InsertItem( &rdi );
  162. _ASSERT( SUCCEEDED(hr) );
  163. }
  164. }
  165. pHeaderCtrl->Release();
  166. pResultData->Release();
  167. }
  168. return hr;
  169. }
  170. CSkateboardFolder::CSkateboardFolder()
  171. {
  172. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  173. children[n] = new CSkateboard(n + 1);
  174. }
  175. }
  176. CSkateboardFolder::~CSkateboardFolder()
  177. {
  178. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  179. if (children[n]) {
  180. delete children[n];
  181. }
  182. }
  183. HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  184. {
  185. HRESULT hr = S_OK;
  186. IHeaderCtrl *pHeaderCtrl = NULL;
  187. IResultData *pResultData = NULL;
  188. if (bShow) {
  189. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  190. _ASSERT( SUCCEEDED(hr) );
  191. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  192. _ASSERT( SUCCEEDED(hr) );
  193. // Set the column headers in the results pane
  194. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  195. _ASSERT( S_OK == hr );
  196. // insert items here
  197. RESULTDATAITEM rdi;
  198. hr = pResultData->DeleteAllRsltItems();
  199. _ASSERT( SUCCEEDED(hr) );
  200. if (!bExpanded) {
  201. // create the child nodes, then expand them
  202. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  203. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  204. rdi.mask = RDI_STR | // Displayname is valid
  205. RDI_IMAGE |
  206. RDI_PARAM; // nImage is valid
  207. rdi.nImage = children[n]->GetBitmapIndex();
  208. rdi.str = MMC_CALLBACK;
  209. rdi.nCol = 0;
  210. rdi.lParam = (LPARAM)children[n];
  211. hr = pResultData->InsertItem( &rdi );
  212. _ASSERT( SUCCEEDED(hr) );
  213. }
  214. }
  215. pHeaderCtrl->Release();
  216. pResultData->Release();
  217. }
  218. return hr;
  219. }
  220. const _TCHAR *CBicycle::GetDisplayName(int nCol)
  221. {
  222. static _TCHAR buf[128];
  223. _stprintf(buf, _T("Bicycle #%d"), id);
  224. return buf;
  225. }
  226. const _TCHAR *CSkateboard::GetDisplayName(int nCol)
  227. {
  228. static _TCHAR buf[128];
  229. _stprintf(buf, _T("Skateboard #%d"), id);
  230. return buf;
  231. }
  232. const _TCHAR *CIceSkate::GetDisplayName(int nCol)
  233. {
  234. static _TCHAR buf[128];
  235. _stprintf(buf, _T("Ice Skate #%d"), id);
  236. return buf;
  237. }