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.

728 lines
22 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 <windows.h>
  20. #include <commctrl.h>
  21. #include <stdio.h>
  22. #include "People.h"
  23. const GUID CPeoplePoweredVehicle::thisGuid = { 0x2974380d, 0x4c4b, 0x11d2, { 0x89, 0xd8, 0x0, 0x0, 0x21, 0x47, 0x31, 0x28 } };
  24. const GUID CBicycleFolder::thisGuid = { 0xef163732, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  25. const GUID CSkateboardFolder::thisGuid = { 0xef163733, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  26. const GUID CIceSkateFolder::thisGuid = { 0xf6c660b0, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  27. const GUID CBicycle::thisGuid = { 0xef163734, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  28. const GUID CSkateboard::thisGuid = { 0xef163735, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  29. const GUID CIceSkate::thisGuid = { 0xf6c660b1, 0x9353, 0x11d2, { 0x99, 0x67, 0x0, 0x80, 0xc7, 0xdc, 0xb3, 0xdc } };
  30. //---------------------------------------------------------------------------
  31. // Creates a string with the format
  32. // "res://<Path to this object>/<path to resource>
  33. //
  34. // It is up to the caller to make sure the memory allocated with
  35. // CoTaskMemAlloc for the string is freed.
  36. // If null is passed in the first parameter, the path to MMC.EXE will be
  37. // returned, if the instance handle is passed the returned path will point
  38. // the Snap-in dll.
  39. //
  40. LPOLESTR CreateResourcePath
  41. (
  42. HINSTANCE hInst, //[in] Global instance handle
  43. LPOLESTR szResource //[in] Path to stored resource
  44. )
  45. {
  46. _TCHAR szBuffer[MAX_PATH];
  47. ZeroMemory(szBuffer, sizeof(szBuffer));
  48. _tcscpy(szBuffer, _T("res://"));
  49. _TCHAR *szTemp = szBuffer + _tcslen(szBuffer);
  50. GetModuleFileName(hInst, szTemp, sizeof(szBuffer) - _tcslen(szBuffer));
  51. _tcscat(szBuffer, _T("/"));
  52. MAKE_TSTRPTR_FROMWIDE(szname, szResource);
  53. _tcscat(szBuffer, szname);
  54. MAKE_WIDEPTR_FROMTSTR(wszname, szBuffer);
  55. LPOLESTR szOutBuffer = static_cast<LPOLESTR>(CoTaskMemAlloc((wcslen(wszname) + 1) * sizeof(WCHAR)));
  56. wcscpy(szOutBuffer, wszname);
  57. return szOutBuffer;
  58. } //end CreateResoucePath()
  59. static LPOLESTR OleDuplicateString(LPOLESTR lpStr) {
  60. LPOLESTR tmp = static_cast<LPOLESTR>(CoTaskMemAlloc((wcslen(lpStr) + 1) * sizeof(WCHAR)));
  61. wcscpy(tmp, lpStr);
  62. return tmp;
  63. }
  64. //==============================================================
  65. //
  66. // CPeoplePoweredVehicle implementation
  67. //
  68. //
  69. CPeoplePoweredVehicle::CPeoplePoweredVehicle()
  70. {
  71. children[0] = new CBicycleFolder;
  72. children[1] = new CSkateboardFolder;
  73. children[2] = new CIceSkateFolder;
  74. }
  75. CPeoplePoweredVehicle::~CPeoplePoweredVehicle()
  76. {
  77. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  78. delete children[n];
  79. }
  80. HRESULT CPeoplePoweredVehicle::OnExpand(IConsoleNameSpace *pConsoleNameSpace, IConsole *pConsole, HSCOPEITEM parent)
  81. {
  82. SCOPEDATAITEM sdi;
  83. if (!bExpanded) {
  84. // create the child nodes, then expand them
  85. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  86. ZeroMemory(&sdi, sizeof(SCOPEDATAITEM) );
  87. sdi.mask = SDI_STR | // Displayname is valid
  88. SDI_PARAM | // lParam is valid
  89. SDI_IMAGE | // nImage is valid
  90. SDI_OPENIMAGE | // nOpenImage is valid
  91. SDI_PARENT | // relativeID is valid
  92. SDI_CHILDREN; // cChildren is valid
  93. sdi.relativeID = (HSCOPEITEM)parent;
  94. sdi.nImage = children[n]->GetBitmapIndex();
  95. sdi.nOpenImage = INDEX_OPENFOLDER;
  96. sdi.displayname = MMC_CALLBACK;
  97. sdi.lParam = (LPARAM)children[n]; // The cookie
  98. sdi.cChildren = 0;
  99. HRESULT hr = pConsoleNameSpace->InsertItem( &sdi );
  100. _ASSERT( SUCCEEDED(hr) );
  101. }
  102. }
  103. return S_OK;
  104. }
  105. CBicycleFolder::CBicycleFolder()
  106. {
  107. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  108. children[n] = new CBicycle(n + 1);
  109. }
  110. }
  111. CBicycleFolder::~CBicycleFolder()
  112. {
  113. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  114. if (children[n]) {
  115. delete children[n];
  116. }
  117. }
  118. HRESULT CBicycleFolder::GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions)
  119. {
  120. TCHAR taskpad[1024];
  121. TCHAR szThis[16];
  122. _ultot((unsigned long)this, szThis, 16);
  123. _tcscpy(taskpad, _T("horizontal.htm#"));
  124. _tcscat(taskpad, szThis);
  125. MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, taskpad);
  126. *ppViewType = CreateResourcePath( NULL, pszW );
  127. *pViewOptions = MMC_VIEW_OPTIONS_NONE;
  128. return S_OK;
  129. }
  130. MMC_TASK *CBicycleFolder::GetTaskList(LPOLESTR szTaskGroup, LONG *nCount)
  131. {
  132. *nCount = 5;
  133. MMC_TASK *tasks = new MMC_TASK[*nCount];
  134. for (int t = 0; t < *nCount; t++) {
  135. tasks[t].sDisplayObject.eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  136. tasks[t].sDisplayObject.uBitmap.szMouseOverBitmap = CreateResourcePath(g_hinst, L"buttonover.bmp");
  137. tasks[t].sDisplayObject.uBitmap.szMouseOffBitmap = CreateResourcePath(g_hinst, L"buttonoff.bmp");
  138. switch (t) {
  139. case 0:
  140. tasks[t].szText = OleDuplicateString(L"Tune bicycle");
  141. tasks[t].szHelpString = OleDuplicateString(L"Click here to Tune bicycle");
  142. break;
  143. case 1:
  144. tasks[t].szText = OleDuplicateString(L"Ride bicycle");
  145. tasks[t].szHelpString = OleDuplicateString(L"Click here to ride bicycle");
  146. break;
  147. case 2:
  148. tasks[t].szText = OleDuplicateString(L"Stop riding bicycle");
  149. tasks[t].szHelpString = OleDuplicateString(L"Click here to stop riding bicycle");
  150. break;
  151. case 3:
  152. tasks[t].szText = OleDuplicateString(L"Purchase bicycle");
  153. tasks[t].szHelpString = OleDuplicateString(L"Click here to purchase bicycle");
  154. case 4:
  155. tasks[t].szText = OleDuplicateString(L"Sell bicycle");
  156. tasks[t].szHelpString = OleDuplicateString(L"Click here to sell bicycle");
  157. break;
  158. }
  159. tasks[t].eActionType = MMC_ACTION_ID;
  160. tasks[t].nCommandID = t;
  161. }
  162. return tasks;
  163. }
  164. HRESULT CBicycleFolder::TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2)
  165. {
  166. RESULTDATAITEM rdi;
  167. IResultData *pResultData;
  168. ZeroMemory(&rdi, sizeof(RESULTDATAITEM));
  169. HRESULT hr = S_OK;
  170. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  171. if (SUCCEEDED(hr)) {
  172. rdi.mask = RDI_STATE | RDI_PARAM; // Use selected state to get param.
  173. rdi.nState = LVIS_SELECTED | LVIS_FOCUSED;
  174. rdi.nIndex = -1; // Start looking for selected item from top of list view
  175. hr = pResultData->GetNextItem(&rdi);
  176. pResultData->Release();
  177. }
  178. if (SUCCEEDED(hr)) {
  179. _TCHAR buf[256];
  180. switch (v1->lVal) {
  181. case 0:
  182. wsprintf(buf, _T("Bicycle %d tuned."), rdi.nIndex);
  183. break;
  184. case 1:
  185. wsprintf(buf, _T("Riding bicycle %d."), rdi.nIndex);
  186. break;
  187. case 2:
  188. wsprintf(buf, _T("Not riding bicycle %d."), rdi.nIndex);
  189. break;
  190. case 3:
  191. wsprintf(buf, _T("Bicycle %d purchased."), rdi.nIndex);
  192. break;
  193. case 4:
  194. wsprintf(buf, _T("Bicycle %d sold."), rdi.nIndex);
  195. break;
  196. case 102:
  197. wsprintf(buf, _T("Special bicycle task choosen (%d)."), rdi.nIndex);
  198. break;
  199. }
  200. MessageBox(NULL, buf, _T("Task Notification"), MB_OK | MB_ICONINFORMATION);
  201. }
  202. return hr;
  203. }
  204. HRESULT CBicycleFolder::GetTaskpadTitle(LPOLESTR *pszTitle)
  205. {
  206. *pszTitle = OleDuplicateString(L"Bicycle Tasks");
  207. return S_OK;
  208. }
  209. HRESULT CBicycleFolder::GetTaskpadDescription(LPOLESTR *pszDescription)
  210. {
  211. *pszDescription = OleDuplicateString(L"This is a sample task pad for bicycle nodes");
  212. return S_OK;
  213. }
  214. HRESULT CBicycleFolder::GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO)
  215. {
  216. pTDO->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  217. pTDO->uBitmap.szMouseOverBitmap = CreateResourcePath(g_hinst, L"bicycle.bmp");
  218. return S_OK;
  219. }
  220. HRESULT CBicycleFolder::GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo)
  221. {
  222. lpListPadInfo->szTitle = OleDuplicateString(L"Bicycle");
  223. lpListPadInfo->szButtonText = OleDuplicateString(L"Special");
  224. lpListPadInfo->nCommandID = 102;
  225. return S_OK;
  226. }
  227. HRESULT CBicycleFolder::OnListpad(IConsole *pConsole, BOOL bAttaching)
  228. {
  229. HRESULT hr = S_OK;
  230. IHeaderCtrl *pHeaderCtrl = NULL;
  231. IResultData *pResultData = NULL;
  232. IImageList *pImageList = NULL;
  233. if (bAttaching) {
  234. hr = pConsole->QueryResultImageList(&pImageList);
  235. _ASSERT( SUCCEEDED(hr) );
  236. hr = pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
  237. (long *)m_pBMapLg, // pointer to a handle
  238. 0, // index of the first image in the strip
  239. RGB(0, 128, 128) // color of the icon mask
  240. );
  241. _ASSERT( SUCCEEDED(hr) );
  242. pImageList->Release();
  243. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  244. _ASSERT( SUCCEEDED(hr) );
  245. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  246. _ASSERT( SUCCEEDED(hr) );
  247. // Set the column headers in the results pane
  248. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  249. _ASSERT( S_OK == hr );
  250. hr = pHeaderCtrl->InsertColumn( 1, L"Bicycle License ", 0, MMCLV_AUTO );
  251. _ASSERT( S_OK == hr );
  252. // insert items here
  253. RESULTDATAITEM rdi;
  254. hr = pResultData->DeleteAllRsltItems();
  255. _ASSERT( SUCCEEDED(hr) );
  256. if (!bExpanded) {
  257. // create the child nodes, then expand them
  258. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  259. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  260. rdi.mask = RDI_STR | // Displayname is valid
  261. RDI_IMAGE |
  262. RDI_PARAM; // nImage is valid
  263. rdi.nImage = children[n]->GetBitmapIndex();
  264. rdi.str = MMC_CALLBACK;
  265. rdi.nCol = 0;
  266. rdi.lParam = (LPARAM)children[n];
  267. hr = pResultData->InsertItem( &rdi );
  268. _ASSERT( SUCCEEDED(hr) );
  269. }
  270. }
  271. pHeaderCtrl->Release();
  272. pResultData->Release();
  273. }
  274. return hr;
  275. }
  276. CIceSkateFolder::CIceSkateFolder()
  277. {
  278. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  279. children[n] = new CIceSkate(n + 1);
  280. }
  281. }
  282. CIceSkateFolder::~CIceSkateFolder()
  283. {
  284. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  285. if (children[n]) {
  286. delete children[n];
  287. }
  288. }
  289. HRESULT CIceSkateFolder::GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions)
  290. {
  291. TCHAR taskpad[1024];
  292. TCHAR szThis[16];
  293. _ultot((unsigned long)this, szThis, 16);
  294. _tcscpy(taskpad, _T("listpad.htm#"));
  295. _tcscat(taskpad, szThis);
  296. MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, taskpad);
  297. *ppViewType = CreateResourcePath( NULL, pszW );
  298. *pViewOptions = MMC_VIEW_OPTIONS_NONE;
  299. return S_OK;
  300. }
  301. MMC_TASK *CIceSkateFolder::GetTaskList(LPOLESTR szTaskGroup, LONG *nCount)
  302. {
  303. *nCount = 4;
  304. MMC_TASK *tasks = new MMC_TASK[*nCount];
  305. for (int t = 0; t < *nCount; t++) {
  306. tasks[t].sDisplayObject.eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  307. tasks[t].sDisplayObject.uBitmap.szMouseOverBitmap = CreateResourcePath(g_hinst, L"buttonover.bmp");
  308. tasks[t].sDisplayObject.uBitmap.szMouseOffBitmap = CreateResourcePath(g_hinst, L"buttonoff.bmp");
  309. switch (t) {
  310. case 0:
  311. tasks[t].szText = OleDuplicateString(L"Sharpen Skate");
  312. tasks[t].szHelpString = OleDuplicateString(L"Click here to Sharpen skate");
  313. break;
  314. case 1:
  315. tasks[t].szText = OleDuplicateString(L"Tighten skate laces");
  316. tasks[t].szHelpString = OleDuplicateString(L"Click here to Tighten skate");
  317. break;
  318. case 2:
  319. tasks[t].szText = OleDuplicateString(L"Wear skate");
  320. tasks[t].szHelpString = OleDuplicateString(L"Click here to Wear skate");
  321. break;
  322. case 3:
  323. tasks[t].szText = OleDuplicateString(L"Remove skate");
  324. tasks[t].szHelpString = OleDuplicateString(L"Click here to Remove skate");
  325. break;
  326. }
  327. tasks[t].eActionType = MMC_ACTION_ID;
  328. tasks[t].nCommandID = t;
  329. }
  330. return tasks;
  331. }
  332. HRESULT CIceSkateFolder::TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2)
  333. {
  334. RESULTDATAITEM rdi;
  335. IResultData *pResultData;
  336. ZeroMemory(&rdi, sizeof(RESULTDATAITEM));
  337. HRESULT hr = S_OK;
  338. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  339. if (SUCCEEDED(hr)) {
  340. rdi.mask = RDI_STATE | RDI_PARAM; // Use selected state to get param.
  341. rdi.nState = LVIS_SELECTED | LVIS_FOCUSED;
  342. rdi.nIndex = -1; // Start looking for selected item from top of list view
  343. hr = pResultData->GetNextItem(&rdi);
  344. pResultData->Release();
  345. }
  346. if (SUCCEEDED(hr)) {
  347. _TCHAR buf[256];
  348. switch (v1->lVal) {
  349. case 0:
  350. wsprintf(buf, _T("Skate %d sharpened."), rdi.nIndex);
  351. break;
  352. case 1:
  353. wsprintf(buf, _T("Skate %d tightened."), rdi.nIndex);
  354. break;
  355. case 2:
  356. wsprintf(buf, _T("Wearing skate %d."), rdi.nIndex);
  357. break;
  358. case 3:
  359. wsprintf(buf, _T("Skate %d removed."), rdi.nIndex);
  360. break;
  361. case 101:
  362. wsprintf(buf, _T("Special skate task choosen (%d)."), rdi.nIndex);
  363. break;
  364. }
  365. MessageBox(NULL, buf, _T("Task Notification"), MB_OK | MB_ICONINFORMATION);
  366. }
  367. return hr;
  368. }
  369. HRESULT CIceSkateFolder::GetTaskpadTitle(LPOLESTR *pszTitle)
  370. {
  371. *pszTitle = OleDuplicateString(L"Iceskate Tasks");
  372. return S_OK;
  373. }
  374. HRESULT CIceSkateFolder::GetTaskpadDescription(LPOLESTR *pszDescription)
  375. {
  376. *pszDescription = OleDuplicateString(L"This is a sample task pad for ice skate nodes");
  377. return S_OK;
  378. }
  379. HRESULT CIceSkateFolder::GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO)
  380. {
  381. pTDO->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  382. pTDO->uBitmap.szMouseOverBitmap = CreateResourcePath(g_hinst, L"iceskate.bmp");
  383. return S_OK;
  384. }
  385. HRESULT CIceSkateFolder::GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo)
  386. {
  387. lpListPadInfo->szTitle = OleDuplicateString(L"Ice Skates");
  388. lpListPadInfo->szButtonText = OleDuplicateString(L"Special");
  389. lpListPadInfo->nCommandID = 101;
  390. return S_OK;
  391. }
  392. HRESULT CIceSkateFolder::OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect)
  393. {
  394. IConsole2 *pConsole2;
  395. HRESULT hr = S_OK;
  396. if (TRUE == bSelect) {
  397. hr = pConsole->QueryInterface(IID_IConsole2, (void **)&pConsole2);
  398. if (SUCCEEDED(hr)) {
  399. hr = pConsole2->SetStatusText(L"Hello, you've selected the ice skate folder");
  400. pConsole2->Release();
  401. }
  402. }
  403. return hr;
  404. }
  405. HRESULT CIceSkateFolder::OnListpad(IConsole *pConsole, BOOL bAttaching)
  406. {
  407. HRESULT hr = S_OK;
  408. IHeaderCtrl *pHeaderCtrl = NULL;
  409. IResultData *pResultData = NULL;
  410. IImageList *pImageList = NULL;
  411. if (bAttaching) {
  412. hr = pConsole->QueryResultImageList(&pImageList);
  413. _ASSERT( SUCCEEDED(hr) );
  414. hr = pImageList->ImageListSetStrip((long *)m_pBMapSm, // pointer to a handle
  415. (long *)m_pBMapLg, // pointer to a handle
  416. 0, // index of the first image in the strip
  417. RGB(0, 128, 128) // color of the icon mask
  418. );
  419. _ASSERT( SUCCEEDED(hr) );
  420. pImageList->Release();
  421. hr = pConsole->QueryInterface(IID_IHeaderCtrl, (void **)&pHeaderCtrl);
  422. _ASSERT( SUCCEEDED(hr) );
  423. hr = pConsole->QueryInterface(IID_IResultData, (void **)&pResultData);
  424. _ASSERT( SUCCEEDED(hr) );
  425. // Set the column headers in the results pane
  426. hr = pHeaderCtrl->InsertColumn( 0, L"Name ", 0, MMCLV_AUTO );
  427. _ASSERT( S_OK == hr );
  428. hr = pHeaderCtrl->InsertColumn( 1, L"Sharpness ", 0, MMCLV_AUTO );
  429. _ASSERT( S_OK == hr );
  430. // insert items here
  431. RESULTDATAITEM rdi;
  432. hr = pResultData->DeleteAllRsltItems();
  433. _ASSERT( SUCCEEDED(hr) );
  434. if (!bExpanded) {
  435. // create the child nodes, then expand them
  436. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  437. ZeroMemory(&rdi, sizeof(RESULTDATAITEM) );
  438. rdi.mask = RDI_STR | // Displayname is valid
  439. RDI_IMAGE |
  440. RDI_PARAM; // nImage is valid
  441. rdi.nImage = children[n]->GetBitmapIndex();
  442. rdi.str = MMC_CALLBACK;
  443. rdi.nCol = 0;
  444. rdi.lParam = (LPARAM)children[n];
  445. hr = pResultData->InsertItem( &rdi );
  446. _ASSERT( SUCCEEDED(hr) );
  447. }
  448. }
  449. pHeaderCtrl->Release();
  450. pResultData->Release();
  451. }
  452. return hr;
  453. }
  454. HRESULT CIceSkate::OnSelect(IConsole *pConsole, BOOL bScope, BOOL bSelect)
  455. {
  456. bSelected = bSelect ? true : false;
  457. return S_FALSE;
  458. }
  459. CSkateboardFolder::CSkateboardFolder()
  460. {
  461. for (int n = 0; n < NUMBER_OF_CHILDREN; n++) {
  462. children[n] = new CSkateboard(n + 1);
  463. }
  464. }
  465. CSkateboardFolder::~CSkateboardFolder()
  466. {
  467. for (int n = 0; n < NUMBER_OF_CHILDREN; n++)
  468. if (children[n]) {
  469. delete children[n];
  470. }
  471. }
  472. HRESULT CSkateboardFolder::GetResultViewType(LPOLESTR *ppViewType, long *pViewOptions)
  473. {
  474. TCHAR taskpad[1024];
  475. TCHAR szThis[16];
  476. _ultot((unsigned long)this, szThis, 16);
  477. _tcscpy(taskpad, _T("default.htm#"));
  478. _tcscat(taskpad, szThis);
  479. MAKE_WIDEPTR_FROMTSTR_ALLOC(pszW, taskpad);
  480. *ppViewType = CreateResourcePath( NULL, pszW );
  481. *pViewOptions = MMC_VIEW_OPTIONS_NONE;
  482. return S_OK;
  483. }
  484. MMC_TASK *CSkateboardFolder::GetTaskList(LPOLESTR szTaskGroup, LONG *nCount)
  485. {
  486. *nCount = 4;
  487. _TCHAR buf[256];
  488. MMC_TASK *tasks = new MMC_TASK[*nCount];
  489. for (int t = 0; t < *nCount; t++) {
  490. tasks[t].sDisplayObject.eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  491. tasks[t].sDisplayObject.uBitmap.szMouseOverBitmap = CreateResourcePath(g_hinst, L"buttonover.bmp");
  492. tasks[t].sDisplayObject.uBitmap.szMouseOffBitmap = CreateResourcePath(g_hinst, L"buttonoff.bmp");
  493. _stprintf(buf, _T("Task #%d"), t);
  494. MAKE_WIDEPTR_FROMTSTR(wszText, buf);
  495. tasks[t].szText = OleDuplicateString(wszText);
  496. _stprintf(buf, _T("Click here to start task #%d"), t);
  497. MAKE_WIDEPTR_FROMTSTR(wszHelpString, buf);
  498. tasks[t].szHelpString = OleDuplicateString(wszHelpString);
  499. tasks[t].eActionType = MMC_ACTION_ID;
  500. tasks[t].nCommandID = t;
  501. }
  502. return tasks;
  503. }
  504. HRESULT CSkateboardFolder::TaskNotify(IConsole *pConsole, VARIANT *v1, VARIANT *v2)
  505. {
  506. _TCHAR buf[256];
  507. wsprintf(buf, _T("Skateboard task %ld has been selected."), v1->lVal);
  508. MessageBox(NULL, buf, _T("Task Notification"), MB_OK | MB_ICONINFORMATION);
  509. return S_OK;
  510. }
  511. HRESULT CSkateboardFolder::GetTaskpadTitle(LPOLESTR *pszTitle)
  512. {
  513. *pszTitle = OleDuplicateString(L"Skateboard Tasks");
  514. return S_OK;
  515. }
  516. HRESULT CSkateboardFolder::GetTaskpadDescription(LPOLESTR *pszDescription)
  517. {
  518. *pszDescription = OleDuplicateString(L"This is a sample task pad for skateboard nodes");
  519. return S_OK;
  520. }
  521. HRESULT CSkateboardFolder::GetTaskpadBackground(MMC_TASK_DISPLAY_OBJECT *pTDO)
  522. {
  523. pTDO->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  524. pTDO->uBitmap.szMouseOverBitmap = CreateResourcePath(g_hinst, L"skateboard.bmp");
  525. return S_OK;
  526. }
  527. HRESULT CSkateboardFolder::GetListpadInfo(MMC_LISTPAD_INFO *lpListPadInfo)
  528. {
  529. return S_FALSE;
  530. }
  531. const _TCHAR *CBicycle::GetDisplayName(int nCol)
  532. {
  533. static _TCHAR buf[128];
  534. if (nCol == 0) {
  535. _stprintf(buf, _T("Bicycle #%d"), id);
  536. } else if (nCol == 1) {
  537. _stprintf(buf, _T("%ld"), (long)this);
  538. }
  539. return buf;
  540. }
  541. const _TCHAR *CSkateboard::GetDisplayName(int nCol)
  542. {
  543. static _TCHAR buf[128];
  544. _stprintf(buf, _T("Skateboard #%d"), id);
  545. return buf;
  546. }
  547. const _TCHAR *CIceSkate::GetDisplayName(int nCol)
  548. {
  549. static _TCHAR buf[128];
  550. if (nCol == 0) {
  551. _stprintf(buf, _T("Ice Skate #%d"), id);
  552. } else if (nCol == 1) {
  553. _stprintf(buf, _T("Sharpness %ld"), (long)this);
  554. }
  555. return buf;
  556. }