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.

329 lines
10 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 "People.h"
  20. const GUID CPeoplePoweredVehicle::thisGuid = { 0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
  21. const GUID CBicycleFolder::thisGuid = { 0xef163732, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  22. const GUID CSkateboardFolder::thisGuid = { 0xef163733, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  23. const GUID CIceSkateFolder::thisGuid = { 0xf6c660b0, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  24. const GUID CBicycle::thisGuid = { 0xef163734, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  25. const GUID CSkateboard::thisGuid = { 0xef163735, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  26. const GUID CIceSkate::thisGuid = { 0xf6c660b1, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  27. //==============================================================
  28. //
  29. // CPeoplePoweredVehicle implementation
  30. //
  31. //
  32. CPeoplePoweredVehicle::CPeoplePoweredVehicle()
  33. {
  34. children[0] = new CBicycleFolder;
  35. children[1] = new CSkateboardFolder;
  36. children[2] = new CIceSkateFolder;
  37. }
  38. CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
  39. {
  40. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  41. delete children[n];
  42. }
  43. HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
  44. {
  45. SCOPEDATAITEM sdi;
  46. if (!bExpanded) {
  47. // create the child nodes, then expand them
  48. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  49. ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
  50. sdi.mask = SDI_STR | // Displayname is valid
  51. SDI_PARAM | // lParam is valid
  52. SDI_IMAGE | // nImage is valid
  53. SDI_OPENIMAGE | // nOpenImage is valid
  54. SDI_PARENT | // relativeID is valid
  55. SDI_CHILDREN; // cChildren is valid
  56. sdi.relativeID = (HSCOPEITEM)parent;
  57. sdi.nImage = children[n]->GetBitmapIndex();
  58. sdi.nOpenImage = INDEX_OPENFOLDER;
  59. sdi.displayname = MMC_CALLBACK;
  60. sdi.lParam = (LPARAM)children[n]; // The cookie
  61. sdi.cChildren = 0;
  62. HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
  63. _ASSERT( SUCCEEDED(hr) );
  64. }
  65. }
  66. return S_OK;
  67. }
  68. CBicycleFolder::CBicycleFolder()
  69. {
  70. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  71. children[n] = new CBicycle(n + 1);
  72. }
  73. }
  74. CBicycleFolder::~CBicycleFolder()
  75. {
  76. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  77. if (children[n]) {
  78. delete children[n];
  79. }
  80. }
  81. HRESULT CBicycleFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  82. {
  83. HRESULT hr = S_OK;
  84. IHeaderCtrl *pHeaderCtrl = NULL;
  85. IResultData *pResultData = NULL;
  86. if (bShow) {
  87. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  88. _ASSERT( SUCCEEDED(hr) );
  89. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  90. _ASSERT( SUCCEEDED(hr) );
  91. // Set the column headers in the results pane
  92. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  93. _ASSERT( S_OK == hr );
  94. // insert items here
  95. RESULTDATAITEM rdi;
  96. hr = pResultData->DeleteAllRsltItems();
  97. _ASSERT( SUCCEEDED(hr) );
  98. if (!bExpanded) {
  99. // create the child nodes, then expand them
  100. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  101. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  102. rdi.mask = RDI_STR | // Displayname is valid
  103. RDI_IMAGE |
  104. RDI_PARAM; // nImage is valid
  105. rdi.nImage = children[n]->GetBitmapIndex();
  106. rdi.str = MMC_CALLBACK;
  107. rdi.nCol = 0;
  108. rdi.lParam = (LPARAM)children[n];
  109. hr = pResultData->InsertItem( &rdi );
  110. _ASSERT( SUCCEEDED(hr) );
  111. }
  112. }
  113. pHeaderCtrl->Release();
  114. pResultData->Release();
  115. }
  116. return hr;
  117. }
  118. CIceSkateFolder::CIceSkateFolder()
  119. {
  120. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  121. children[n] = new CIceSkate(n + 1);
  122. }
  123. }
  124. CIceSkateFolder::~CIceSkateFolder()
  125. {
  126. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  127. if (children[n]) {
  128. delete children[n];
  129. }
  130. }
  131. HRESULT CIceSkateFolder::GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions)
  132. {
  133. *ppViewType = NULL;
  134. *pViewOptions = MMC_VIEW_OPTIONS_OWNERDATALIST;
  135. return S_OK;
  136. }
  137. void CIceSkateFolder::GetChildColumnInfo(RESULTDATAITEM *rdi)
  138. {
  139. if (rdi->mask & RDI_STR) {
  140. LPCTSTR pszT = children[rdi->nIndex]->GetDisplayName(rdi->nCol);
  141. MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, pszT);
  142. rdi->str = pszW;
  143. }
  144. if (rdi->mask & RDI_IMAGE)
  145. rdi->nImage = children[rdi->nIndex]->GetBitmapIndex();
  146. }
  147. // CDelegationBase::AddImages sets up the collection of images to be displayed
  148. // by the IComponent in the result pane as a result of its MMCN_SHOW handler
  149. HRESULT CIceSkateFolder::OnAddImages(IImageList *pImageList, HSCOPEITEM hsi)
  150. {
  151. return pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
  152. (long *)m_pBMapLg, // pointer to a handle
  153. 0, // index of the first image in the strip
  154. RGB(0, 128, 128) // color of the icon mask
  155. );
  156. }
  157. HRESULT CIceSkateFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  158. {
  159. HRESULT hr = S_OK;
  160. IHeaderCtrl *pHeaderCtrl = NULL;
  161. IResultData *pResultData = NULL;
  162. if (bShow) {
  163. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  164. _ASSERT( SUCCEEDED(hr) );
  165. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  166. _ASSERT( SUCCEEDED(hr) );
  167. // Set the column headers in the results pane
  168. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  169. _ASSERT( S_OK == hr );
  170. hr = pResultData->DeleteAllRsltItems();
  171. _ASSERT( SUCCEEDED(hr) );
  172. if (!bExpanded) {
  173. // create the child nodes, then expand them
  174. hr = pResultData->SetItemCount( NUMBER_OF_CHILDREN, 0 );
  175. _ASSERT( SUCCEEDED(hr) );
  176. }
  177. pHeaderCtrl->Release();
  178. pResultData->Release();
  179. }
  180. return hr;
  181. }
  182. CSkateboardFolder::CSkateboardFolder()
  183. {
  184. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  185. children[n] = new CSkateboard(n + 1);
  186. }
  187. }
  188. CSkateboardFolder::~CSkateboardFolder()
  189. {
  190. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  191. if (children[n]) {
  192. delete children[n];
  193. }
  194. }
  195. HRESULT CSkateboardFolder::OnShow(IConsole *pConsole, BOOL bShow, HSCOPEITEM scopeitem)
  196. {
  197. HRESULT hr = S_OK;
  198. IHeaderCtrl *pHeaderCtrl = NULL;
  199. IResultData *pResultData = NULL;
  200. if (bShow) {
  201. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  202. _ASSERT( SUCCEEDED(hr) );
  203. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  204. _ASSERT( SUCCEEDED(hr) );
  205. // Set the column headers in the results pane
  206. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  207. _ASSERT( S_OK == hr );
  208. // insert items here
  209. RESULTDATAITEM rdi;
  210. hr = pResultData->DeleteAllRsltItems();
  211. _ASSERT( SUCCEEDED(hr) );
  212. if (!bExpanded) {
  213. // create the child nodes, then expand them
  214. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  215. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  216. rdi.mask = RDI_STR | // Displayname is valid
  217. RDI_IMAGE |
  218. RDI_PARAM; // nImage is valid
  219. rdi.nImage = children[n]->GetBitmapIndex();
  220. rdi.str = MMC_CALLBACK;
  221. rdi.nCol = 0;
  222. rdi.lParam = (LPARAM)children[n];
  223. hr = pResultData->InsertItem( &rdi );
  224. _ASSERT( SUCCEEDED(hr) );
  225. }
  226. }
  227. pHeaderCtrl->Release();
  228. pResultData->Release();
  229. }
  230. return hr;
  231. }
  232. const _TCHAR *CBicycle::GetDisplayName(int nCol)
  233. {
  234. _TCHAR buf[128];
  235. wsprintf(buf, _T("Bicycle #%d"), id);
  236. _TCHAR *pszCol =
  237. static_cast<_TCHAR *>(CoTaskMemAlloc((_tcslen(buf) + 1) * sizeof(WCHAR)));
  238. _tcscpy(pszCol, buf);
  239. return pszCol;
  240. }
  241. const _TCHAR *CSkateboard::GetDisplayName(int nCol)
  242. {
  243. _TCHAR buf[128];
  244. wsprintf(buf, _T("Skateboard #%d"), id);
  245. _TCHAR *pszCol =
  246. static_cast<_TCHAR *>(CoTaskMemAlloc((_tcslen(buf) + 1) * sizeof(WCHAR)));
  247. _tcscpy(pszCol, buf);
  248. return pszCol;
  249. }
  250. const _TCHAR *CIceSkate::GetDisplayName(int nCol)
  251. {
  252. _TCHAR buf[128];
  253. wsprintf(buf, _T("Ice Skate #%d"), id);
  254. _TCHAR *pszCol =
  255. static_cast<_TCHAR *>(CoTaskMemAlloc((_tcslen(buf) + 1) * sizeof(WCHAR)));
  256. _tcscpy(pszCol, buf);
  257. return pszCol;
  258. }