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.

324 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 = { 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. children[n]->SetHandle((HANDLE)sdi.ID);
  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. children[n]->SetHandle((HANDLE)rdi.itemID);
  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::GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions)
  135. {
  136. *ppViewType = NULL;
  137. *pViewOptions = MMC_VIEW_OPTIONS_OWNERDATALIST;
  138. return S_OK;
  139. }
  140. void CIceSkateFolder::GetChildColumnInfo(RESULTDATAITEM *rdi)
  141. {
  142. if (rdi->mask & RDI_STR)
  143. {
  144. LPCTSTR pszT = children[rdi->nIndex]->GetDisplayName(rdi->nCol);
  145. MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
  146. rdi->str = pszW;
  147. }
  148. if (rdi->mask & RDI_IMAGE)
  149. rdi->nImage = children[rdi->nIndex]->GetBitmapIndex();
  150. }
  151. // CDelegationBase::AddImages sets up the collection of images to be displayed
  152. // by the IComponent in the result pane as a result of its MMCN_SHOW handler
  153. HRESULT CIceSkateFolder::OnAddImages(IImageList *pImageList, HSCOPEITEM hsi)
  154. {
  155. return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
  156. (long *)m_pBMapLg, // pointer to a handle
  157. 0, // index of the first image in the strip
  158. RGB(0, 128, 128) // color of the icon mask
  159. );
  160. }
  161. HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  162. {
  163. HRESULT hr = S_OK;
  164. IHeaderCtrl *pHeaderCtrl = NULL;
  165. IResultData *pResultData = NULL;
  166. if (bShow) {
  167. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  168. _ASSERT( SUCCEEDED(hr) );
  169. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  170. _ASSERT( SUCCEEDED(hr) );
  171. // Set the column headers in the results pane
  172. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  173. _ASSERT( S_OK == hr );
  174. hr = pResultData->DeleteAllRsltItems();
  175. _ASSERT( SUCCEEDED(hr) );
  176. if (!bExpanded) {
  177. // create the child nodes, then expand them
  178. hr = pResultData->SetItemCount( NUMBER_OF_CHILDREN, 0 );
  179. _ASSERT( SUCCEEDED(hr) );
  180. }
  181. pHeaderCtrl->Release();
  182. pResultData->Release();
  183. }
  184. return hr;
  185. }
  186. CSkateboardFolder::CSkateboardFolder()
  187. {
  188. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  189. children[n] = new CSkateboard(n + 1);
  190. }
  191. }
  192. CSkateboardFolder::~CSkateboardFolder()
  193. {
  194. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  195. if (children[n]) {
  196. delete children[n];
  197. }
  198. }
  199. HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  200. {
  201. HRESULT hr = S_OK;
  202. IHeaderCtrl *pHeaderCtrl = NULL;
  203. IResultData *pResultData = NULL;
  204. if (bShow) {
  205. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  206. _ASSERT( SUCCEEDED(hr) );
  207. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  208. _ASSERT( SUCCEEDED(hr) );
  209. // Set the column headers in the results pane
  210. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  211. _ASSERT( S_OK == hr );
  212. // insert items here
  213. RESULTDATAITEM rdi;
  214. hr = pResultData->DeleteAllRsltItems();
  215. _ASSERT( SUCCEEDED(hr) );
  216. if (!bExpanded) {
  217. // create the child nodes, then expand them
  218. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  219. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  220. rdi.mask = RDI_STR | // Displayname is valid
  221. RDI_IMAGE |
  222. RDI_PARAM; // nImage is valid
  223. rdi.nImage = children[n]->GetBitmapIndex();
  224. rdi.str = MMC_CALLBACK;
  225. rdi.nCol = 0;
  226. rdi.lParam = (LPARAM)children[n];
  227. hr = pResultData->InsertItem( &rdi );
  228. _ASSERT( SUCCEEDED(hr) );
  229. children[n]->SetHandle((HANDLE)rdi.itemID);
  230. }
  231. }
  232. pHeaderCtrl->Release();
  233. pResultData->Release();
  234. }
  235. return hr;
  236. }
  237. const _TCHAR *CBicycle::GetDisplayName(int nCol)
  238. {
  239. static _TCHAR buf[128];
  240. _stprintf(buf, _T("Bicycle #%d"), id);
  241. return buf;
  242. }
  243. const _TCHAR *CSkateboard::GetDisplayName(int nCol)
  244. {
  245. static _TCHAR buf[128];
  246. _stprintf(buf, _T("Skateboard #%d"), id);
  247. return buf;
  248. }
  249. const _TCHAR *CIceSkate::GetDisplayName(int nCol)
  250. {
  251. static _TCHAR buf[128];
  252. _stprintf(buf, _T("Ice Skate #%d"), id);
  253. return buf;
  254. }