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.

1920 lines
54 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. node.cpp
  7. Root node information (the root node is not displayed
  8. in the MMC framework but contains information such as
  9. all of the subnodes in this snapin).
  10. FILE HISTORY:
  11. */
  12. #include "stdafx.h"
  13. #include "basehand.h"
  14. #include "util.h"
  15. DEBUG_DECLARE_INSTANCE_COUNTER(CBaseHandler);
  16. /*!--------------------------------------------------------------------------
  17. CBaseHandler::CBaseHandler
  18. -
  19. Author: KennT
  20. ---------------------------------------------------------------------------*/
  21. CBaseHandler::CBaseHandler(ITFSComponentData *pTFSCompData)
  22. : m_cRef(1)
  23. {
  24. DEBUG_INCREMENT_INSTANCE_COUNTER(CBaseHandler);
  25. m_spTFSCompData.Set(pTFSCompData);
  26. pTFSCompData->GetNodeMgr(&m_spNodeMgr);
  27. }
  28. CBaseHandler::~CBaseHandler()
  29. {
  30. DEBUG_DECREMENT_INSTANCE_COUNTER(CBaseHandler);
  31. }
  32. IMPLEMENT_ADDREF_RELEASE(CBaseHandler)
  33. STDMETHODIMP CBaseHandler::QueryInterface(REFIID riid, LPVOID *ppv)
  34. {
  35. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  36. // Is the pointer bad?
  37. if (ppv == NULL)
  38. return E_INVALIDARG;
  39. // Place NULL in *ppv in case of failure
  40. *ppv = NULL;
  41. // This is the non-delegating IUnknown implementation
  42. if (riid == IID_IUnknown)
  43. *ppv = (LPVOID) this;
  44. else if (riid == IID_ITFSNodeHandler)
  45. *ppv = (ITFSNodeHandler *) this;
  46. // If we're going to return an interface, AddRef it first
  47. if (*ppv)
  48. {
  49. ((LPUNKNOWN) *ppv)->AddRef();
  50. return hrOK;
  51. }
  52. else
  53. return E_NOINTERFACE;
  54. }
  55. STDMETHODIMP CBaseHandler::DestroyHandler(ITFSNode *pNode)
  56. {
  57. return hrOK;
  58. }
  59. /*!--------------------------------------------------------------------------
  60. CBaseHandler::Notify
  61. Implementation of ITFSNodeHandler::Notify
  62. Author: KennT
  63. ---------------------------------------------------------------------------*/
  64. STDMETHODIMP CBaseHandler::Notify(ITFSNode *pNode, IDataObject *pDataObject,
  65. DWORD dwType, MMC_NOTIFY_TYPE event,
  66. LPARAM arg, LPARAM lParam)
  67. {
  68. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  69. HRESULT hr = hrOK;
  70. switch (event)
  71. {
  72. case MMCN_PROPERTY_CHANGE:
  73. hr = OnPropertyChange(pNode, pDataObject, dwType, arg, lParam);
  74. break;
  75. case MMCN_EXPAND:
  76. {
  77. // when MMC calls us to expand the root node, it
  78. // hands us the scopeID. We need to save it off here.
  79. SPITFSNode spRootNode;
  80. m_spNodeMgr->GetRootNode(&spRootNode);
  81. if (pNode == spRootNode)
  82. pNode->SetData(TFS_DATA_SCOPEID, lParam);
  83. // now walk the list of children for this node and
  84. // show them (they may have been added to the internal tree,
  85. // but not the UI before this node was expanded
  86. SPITFSNodeEnum spNodeEnum;
  87. ITFSNode * pCurrentNode;
  88. ULONG nNumReturned = 0;
  89. pNode->GetEnum(&spNodeEnum);
  90. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  91. while (nNumReturned)
  92. {
  93. if (pCurrentNode->IsVisible() && !pCurrentNode->IsInUI())
  94. pCurrentNode->Show();
  95. pCurrentNode->Release();
  96. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  97. }
  98. // Now call the notification handler for specific functionality
  99. hr = OnExpand(pNode, pDataObject, dwType, arg, lParam);
  100. }
  101. break;
  102. case MMCN_DELETE:
  103. hr = OnDelete(pNode, arg, lParam);
  104. break;
  105. case MMCN_RENAME:
  106. hr = OnRename(pNode, arg, lParam);
  107. break;
  108. /* case MMCN_CONTEXTMENU:
  109. hr = OnContextMenu(pNode, arg, lParam);
  110. break;
  111. */
  112. case MMCN_REMOVE_CHILDREN:
  113. hr = OnRemoveChildren(pNode, pDataObject, arg, lParam);
  114. break;
  115. case MMCN_EXPANDSYNC:
  116. hr = OnExpandSync(pNode, pDataObject, arg, lParam);
  117. break;
  118. case MMCN_BTN_CLICK:
  119. switch (lParam)
  120. {
  121. case MMC_VERB_COPY:
  122. hr = OnVerbCopy(pNode, arg, lParam);
  123. break;
  124. case MMC_VERB_PASTE:
  125. hr = OnVerbPaste(pNode, arg, lParam);
  126. break;
  127. case MMC_VERB_DELETE:
  128. hr = OnVerbDelete(pNode, arg, lParam);
  129. break;
  130. case MMC_VERB_PROPERTIES:
  131. hr = OnVerbProperties(pNode, arg, lParam);
  132. break;
  133. case MMC_VERB_RENAME:
  134. hr = OnVerbRename(pNode, arg, lParam);
  135. break;
  136. case MMC_VERB_REFRESH:
  137. hr = OnVerbRefresh(pNode, arg, lParam);
  138. break;
  139. case MMC_VERB_PRINT:
  140. hr = OnVerbPrint(pNode, arg, lParam);
  141. break;
  142. };
  143. break;
  144. case MMCN_RESTORE_VIEW:
  145. hr = OnRestoreView(pNode, arg, lParam);
  146. break;
  147. default:
  148. Panic1("Uknown event in CBaseHandler::Notify! 0x%x", event); // Handle new messages
  149. hr = S_FALSE;
  150. break;
  151. }
  152. return hr;
  153. }
  154. /*!--------------------------------------------------------------------------
  155. CBaseHandler::CreatePropertyPages
  156. Implementation of ITFSNodeHandler::CreatePropertyPages
  157. Author: KennT
  158. ---------------------------------------------------------------------------*/
  159. STDMETHODIMP CBaseHandler::CreatePropertyPages(ITFSNode *pNode,
  160. LPPROPERTYSHEETCALLBACK lpProvider,
  161. LPDATAOBJECT pDataObject,
  162. LONG_PTR handle,
  163. DWORD dwType)
  164. {
  165. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  166. HRESULT hr = hrOK;
  167. if (dwType & TFS_COMPDATA_CREATE)
  168. {
  169. // This is the case where we are asked to bring up property
  170. // pages when the user is adding a new snapin. These calls
  171. // are forwarded to the root node to handle.
  172. SPITFSNode spRootNode;
  173. SPITFSNodeHandler spHandler;
  174. // get the root node
  175. m_spNodeMgr->GetRootNode(&spRootNode);
  176. spRootNode->GetHandler(&spHandler);
  177. spHandler->CreatePropertyPages(spRootNode, lpProvider, pDataObject,
  178. handle, dwType);
  179. }
  180. return hr;
  181. }
  182. /*!--------------------------------------------------------------------------
  183. CBaseHandler::HasPropertyPages
  184. Implementation of ITFSNodeHandler::HasPropertyPages
  185. Author: KennT
  186. ---------------------------------------------------------------------------*/
  187. STDMETHODIMP CBaseHandler::HasPropertyPages(ITFSNode *pNode,
  188. LPDATAOBJECT pDataObject,
  189. DATA_OBJECT_TYPES type,
  190. DWORD dwType)
  191. {
  192. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  193. HRESULT hr = hrOK;
  194. if (dwType & TFS_COMPDATA_CREATE)
  195. {
  196. // This is the case where we are asked to bring up property
  197. // pages when the user is adding a new snapin. These calls
  198. // are forwarded to the root node to handle.
  199. SPITFSNode spRootNode;
  200. SPITFSNodeHandler spHandler;
  201. // get the root node
  202. m_spNodeMgr->GetRootNode(&spRootNode);
  203. spRootNode->GetHandler(&spHandler);
  204. hr = spHandler->HasPropertyPages(spRootNode, pDataObject, type, dwType);
  205. }
  206. else
  207. {
  208. // we have no property pages in the normal case
  209. hr = S_FALSE;
  210. }
  211. return hr;
  212. }
  213. /*!--------------------------------------------------------------------------
  214. CBaseHandler::OnAddMenuItems
  215. Implementation of ITFSNodeHandler::OnAddMenuItems
  216. Author: KennT
  217. ---------------------------------------------------------------------------*/
  218. STDMETHODIMP CBaseHandler::OnAddMenuItems(ITFSNode *pNode,
  219. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  220. LPDATAOBJECT lpDataObject,
  221. DATA_OBJECT_TYPES type,
  222. DWORD dwType,
  223. long *pInsertionAllowed)
  224. {
  225. return S_FALSE;
  226. }
  227. /*!--------------------------------------------------------------------------
  228. CBaseHandler::OnCommand
  229. Implementation of ITFSNodeHandler::OnCommand
  230. Author: KennT
  231. ---------------------------------------------------------------------------*/
  232. STDMETHODIMP CBaseHandler::OnCommand(ITFSNode *pNode,
  233. long nCommandId,
  234. DATA_OBJECT_TYPES type,
  235. LPDATAOBJECT pDataObject,
  236. DWORD dwType)
  237. {
  238. return S_FALSE;
  239. }
  240. /*!--------------------------------------------------------------------------
  241. CBaseHandler::GetString
  242. Implementation of ITFSNodeHandler::GetString
  243. Author: KennT
  244. ---------------------------------------------------------------------------*/
  245. STDMETHODIMP_(LPCTSTR)CBaseHandler::GetString(ITFSNode *pNode, int nCol)
  246. {
  247. return _T("Foo");
  248. }
  249. /*!--------------------------------------------------------------------------
  250. CBaseHandler::UserNotify
  251. Implememntation of ITFSNodeHandler::UserNotify
  252. Author: KennT
  253. ---------------------------------------------------------------------------*/
  254. STDMETHODIMP CBaseHandler::UserNotify(ITFSNode *pNode, LPARAM dwParam1, LPARAM dwParam2)
  255. {
  256. return S_FALSE;
  257. }
  258. /*!--------------------------------------------------------------------------
  259. CBaseHandler::OnCreateDataObject
  260. Implementation of ITFSNodeHandler::OnCreateDataObject
  261. Author: KennT
  262. ---------------------------------------------------------------------------*/
  263. STDMETHODIMP CBaseHandler::OnCreateDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  264. {
  265. // this relies on the ComponentData to do this work
  266. return S_FALSE;
  267. }
  268. /*!--------------------------------------------------------------------------
  269. CBaseHandler::CreateNodeId2
  270. Implementation of ITFSNodeHandler::CreateNodeId2
  271. Author: KennT
  272. ---------------------------------------------------------------------------*/
  273. STDMETHODIMP CBaseHandler::CreateNodeId2(ITFSNode * pNode, BSTR * pbstrId, DWORD * pdwFlags)
  274. {
  275. HRESULT hr = S_FALSE;
  276. CString strId;
  277. COM_PROTECT_TRY
  278. {
  279. if (pbstrId == NULL)
  280. return hr;
  281. // call the handler function to get the data
  282. hr = OnCreateNodeId2(pNode, strId, pdwFlags);
  283. if (SUCCEEDED(hr) && hr != S_FALSE)
  284. {
  285. *pbstrId = ::SysAllocString((LPOLESTR) (LPCTSTR) strId);
  286. }
  287. }
  288. COM_PROTECT_CATCH
  289. return hr;
  290. }
  291. /*---------------------------------------------------------------------------
  292. CBaseHandler Notifications
  293. ---------------------------------------------------------------------------*/
  294. HRESULT CBaseHandler::OnPropertyChange(ITFSNode *pNode, LPDATAOBJECT pDataobject, DWORD dwType, LPARAM arg, LPARAM lParam)
  295. {
  296. Trace0("IComponentData::Notify(MMCN_PROPERTY_CHANGE) received\n");
  297. return S_FALSE;
  298. }
  299. HRESULT CBaseHandler::OnDelete(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  300. {
  301. Trace0("IComponentData::Notify(MMCN_DELETE) received\n");
  302. return S_FALSE;
  303. }
  304. HRESULT CBaseHandler::OnRename(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  305. {
  306. Trace0("IComponentData::Notify(MMCN_RENAME) received\n");
  307. return S_FALSE;
  308. }
  309. HRESULT CBaseHandler::OnExpand(ITFSNode *pNode, LPDATAOBJECT pDataObject, DWORD dwType, LPARAM arg, LPARAM lParam)
  310. {
  311. Trace0("IComponentData::Notify(MMCN_EXPAND) received\n");
  312. return hrOK;
  313. }
  314. HRESULT CBaseHandler::OnRemoveChildren(ITFSNode *pNode, LPDATAOBJECT pDataObject, LPARAM arg, LPARAM lParam)
  315. {
  316. Trace0("IComponentData::Notify(MMCN_REMOVECHILDREN) received\n");
  317. return S_FALSE;
  318. }
  319. HRESULT CBaseHandler::OnExpandSync(ITFSNode *pNode, LPDATAOBJECT pDataObject, LPARAM arg, LPARAM lParam)
  320. {
  321. Trace0("IComponentData::Notify(MMCN_EXPANDSYNC) received\n");
  322. return S_FALSE;
  323. }
  324. HRESULT CBaseHandler::OnContextMenu(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  325. {
  326. Trace0("IComponentData::Notify(MMCN_CONTEXTMENU) received\n");
  327. return S_FALSE;
  328. }
  329. HRESULT CBaseHandler::OnVerbCopy(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  330. {
  331. Trace0("IComponentData::Notify(MMCN_VERB_COPY) received\n");
  332. return S_FALSE;
  333. }
  334. HRESULT CBaseHandler::OnVerbPaste(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  335. {
  336. Trace0("IComponentData::Notify(MMCN_VERB_PASTE) received\n");
  337. return S_FALSE;
  338. }
  339. HRESULT CBaseHandler::OnVerbDelete(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  340. {
  341. Trace0("IComponentData::Notify(MMCN_VERB_DELETE) received\n");
  342. return S_FALSE;
  343. }
  344. HRESULT CBaseHandler::OnVerbProperties(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  345. {
  346. Trace0("IComponentData::Notify(MMCN_VERB_PROPERTIES) received\n");
  347. return S_FALSE;
  348. }
  349. HRESULT CBaseHandler::OnVerbRename(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  350. {
  351. Trace0("IComponentData::Notify(MMCN_VERB_RENAME) received\n");
  352. return S_FALSE;
  353. }
  354. HRESULT CBaseHandler::OnVerbRefresh(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  355. {
  356. Trace0("IComponentData::Notify(MMCN_VERB_REFRESH) received\n");
  357. return S_FALSE;
  358. }
  359. HRESULT CBaseHandler::OnVerbPrint(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  360. {
  361. Trace0("IComponentData::Notify(MMCN_VERB_PRINT) received\n");
  362. return S_FALSE;
  363. }
  364. HRESULT CBaseHandler::OnRestoreView(ITFSNode *pNode, LPARAM arg, LPARAM lParam)
  365. {
  366. Trace0("IComponentData::Notify(MMCN_RESTORE_VIEW) received\n");
  367. return S_FALSE;
  368. }
  369. HRESULT CBaseHandler::OnCreateNodeId2(ITFSNode * pNode, CString & strId, DWORD * pdwFlags)
  370. {
  371. return S_FALSE;
  372. }
  373. DEBUG_DECLARE_INSTANCE_COUNTER(CBaseResultHandler);
  374. /*---------------------------------------------------------------------------
  375. CBaseResultHandler implementation
  376. ---------------------------------------------------------------------------*/
  377. CBaseResultHandler::CBaseResultHandler(ITFSComponentData *pTFSCompData)
  378. : m_cRef(1)
  379. {
  380. DEBUG_INCREMENT_INSTANCE_COUNTER(CBaseResultHandler);
  381. m_spTFSComponentData.Set(pTFSCompData);
  382. pTFSCompData->GetNodeMgr(&m_spResultNodeMgr);
  383. m_nColumnFormat = LVCFMT_LEFT; // default column alignment
  384. m_pColumnStringIDs = NULL;
  385. m_pColumnWidths = NULL;
  386. m_fMessageView = FALSE;
  387. }
  388. CBaseResultHandler::~CBaseResultHandler()
  389. {
  390. DEBUG_DECREMENT_INSTANCE_COUNTER(CBaseResultHandler);
  391. }
  392. IMPLEMENT_ADDREF_RELEASE(CBaseResultHandler)
  393. STDMETHODIMP CBaseResultHandler::QueryInterface(REFIID riid, LPVOID *ppv)
  394. {
  395. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  396. // Is the pointer bad?
  397. if (ppv == NULL)
  398. return E_INVALIDARG;
  399. // Place NULL in *ppv in case of failure
  400. *ppv = NULL;
  401. // This is the non-delegating IUnknown implementation
  402. if (riid == IID_IUnknown)
  403. *ppv = (LPVOID) this;
  404. else if (riid == IID_ITFSResultHandler)
  405. *ppv = (ITFSResultHandler *) this;
  406. // If we're going to return an interface, AddRef it first
  407. if (*ppv)
  408. {
  409. ((LPUNKNOWN) *ppv)->AddRef();
  410. return hrOK;
  411. }
  412. else
  413. return E_NOINTERFACE;
  414. }
  415. STDMETHODIMP CBaseResultHandler::DestroyResultHandler(MMC_COOKIE cookie)
  416. {
  417. return hrOK;
  418. }
  419. /*!--------------------------------------------------------------------------
  420. CBaseResultHandler::Notify
  421. Implementation of ITFSResultHandler::Notify
  422. Author: KennT
  423. ---------------------------------------------------------------------------*/
  424. STDMETHODIMP
  425. CBaseResultHandler::Notify
  426. (
  427. ITFSComponent * pComponent,
  428. MMC_COOKIE cookie,
  429. LPDATAOBJECT pDataObject,
  430. MMC_NOTIFY_TYPE event,
  431. LPARAM arg,
  432. LPARAM param
  433. )
  434. {
  435. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  436. HRESULT hr = S_OK;
  437. pComponent->SetCurrentDataObject(pDataObject);
  438. COM_PROTECT_TRY
  439. {
  440. switch(event)
  441. {
  442. case MMCN_PROPERTY_CHANGE:
  443. hr = OnResultPropertyChange(pComponent, pDataObject, cookie, arg, param);
  444. break;
  445. case MMCN_ACTIVATE:
  446. hr = OnResultActivate(pComponent, cookie, arg, param);
  447. break;
  448. case MMCN_CLICK:
  449. hr = OnResultItemClkOrDblClk(pComponent, cookie, arg, param, FALSE);
  450. break;
  451. case MMCN_COLUMN_CLICK:
  452. hr = OnResultColumnClick(pComponent, arg, (BOOL)param);
  453. break;
  454. case MMCN_COLUMNS_CHANGED:
  455. hr = OnResultColumnsChanged(pComponent, pDataObject,
  456. (MMC_VISIBLE_COLUMNS *) param);
  457. break;
  458. case MMCN_DBLCLICK:
  459. hr = OnResultItemClkOrDblClk(pComponent, cookie, arg, param, TRUE);
  460. break;
  461. case MMCN_SHOW:
  462. {
  463. CWaitCursor wait;
  464. hr = OnResultShow(pComponent, cookie, arg, param);
  465. }
  466. break;
  467. case MMCN_SELECT:
  468. hr = OnResultSelect(pComponent, pDataObject, cookie, arg, param);
  469. break;
  470. case MMCN_INITOCX:
  471. hr = OnResultInitOcx(pComponent, pDataObject, cookie, arg, param);
  472. break;
  473. case MMCN_MINIMIZED:
  474. hr = OnResultMinimize(pComponent, cookie, arg, param);
  475. break;
  476. case MMCN_DELETE:
  477. hr = OnResultDelete(pComponent, pDataObject, cookie, arg, param);
  478. break;
  479. case MMCN_RENAME:
  480. hr = OnResultRename(pComponent, pDataObject, cookie, arg, param);
  481. break;
  482. case MMCN_REFRESH:
  483. hr = OnResultRefresh(pComponent, pDataObject, cookie, arg, param);
  484. break;
  485. case MMCN_CONTEXTHELP:
  486. hr = OnResultContextHelp(pComponent, pDataObject, cookie, arg, param);
  487. break;
  488. case MMCN_QUERY_PASTE:
  489. hr = OnResultQueryPaste(pComponent, pDataObject, cookie, arg, param);
  490. break;
  491. case MMCN_BTN_CLICK:
  492. switch (param)
  493. {
  494. case MMC_VERB_COPY:
  495. OnResultVerbCopy(pComponent, cookie, arg, param);
  496. break;
  497. case MMC_VERB_PASTE:
  498. OnResultVerbPaste(pComponent, cookie, arg, param);
  499. break;
  500. case MMC_VERB_DELETE:
  501. OnResultVerbDelete(pComponent, cookie, arg, param);
  502. break;
  503. case MMC_VERB_PROPERTIES:
  504. OnResultVerbProperties(pComponent, cookie, arg, param);
  505. break;
  506. case MMC_VERB_RENAME:
  507. OnResultVerbRename(pComponent, cookie, arg, param);
  508. break;
  509. case MMC_VERB_REFRESH:
  510. OnResultVerbRefresh(pComponent, cookie, arg, param);
  511. break;
  512. case MMC_VERB_PRINT:
  513. OnResultVerbPrint(pComponent, cookie, arg, param);
  514. break;
  515. default:
  516. break;
  517. }
  518. break;
  519. case MMCN_RESTORE_VIEW:
  520. hr = OnResultRestoreView(pComponent, cookie, arg, param);
  521. break;
  522. // Note - Future expansion of notify types possible
  523. default:
  524. Panic1("Uknown event in CBaseResultHandler::Notify! 0x%x", event); // Handle new messages
  525. hr = S_FALSE;
  526. break;
  527. }
  528. }
  529. COM_PROTECT_CATCH
  530. pComponent->SetCurrentDataObject(NULL);
  531. return hr;
  532. }
  533. /*!--------------------------------------------------------------------------
  534. CBaseResultHandler::OnUpdateView
  535. Implementation of ITFSResultHandler::UpdateView
  536. Author: KennT
  537. ---------------------------------------------------------------------------*/
  538. STDMETHODIMP
  539. CBaseResultHandler::UpdateView
  540. (
  541. ITFSComponent * pComponent,
  542. LPDATAOBJECT pDataObject,
  543. LPARAM data,
  544. LPARAM hint
  545. )
  546. {
  547. return OnResultUpdateView(pComponent, pDataObject, data, hint);
  548. }
  549. /*!--------------------------------------------------------------------------
  550. CBaseResultHandler::GetString
  551. Implementation of ITFSResultHandler::GetString
  552. Author: KennT
  553. ---------------------------------------------------------------------------*/
  554. STDMETHODIMP_(LPCTSTR)
  555. CBaseResultHandler::GetString
  556. (
  557. ITFSComponent * pComponent,
  558. MMC_COOKIE cookie,
  559. int nCol
  560. )
  561. {
  562. return NULL;
  563. }
  564. /*!--------------------------------------------------------------------------
  565. CBaseResultHandler::CompareItems
  566. Implementation of ITFSResultHandler::CompareItems
  567. Author: KennT
  568. ---------------------------------------------------------------------------*/
  569. STDMETHODIMP_(int)
  570. CBaseResultHandler::CompareItems
  571. (
  572. ITFSComponent * pComponent,
  573. MMC_COOKIE cookieA,
  574. MMC_COOKIE cookieB,
  575. int nCol
  576. )
  577. {
  578. return S_FALSE;
  579. }
  580. /*!--------------------------------------------------------------------------
  581. CBaseResultHandler::FindItem
  582. called when the Virutal listbox needs to find an item.
  583. Author: EricDav
  584. ---------------------------------------------------------------------------*/
  585. STDMETHODIMP
  586. CBaseResultHandler::FindItem
  587. (
  588. LPRESULTFINDINFO pFindInfo,
  589. int * pnFoundIndex
  590. )
  591. {
  592. return S_FALSE;
  593. }
  594. /*!--------------------------------------------------------------------------
  595. CBaseResultHandler::CacheHint
  596. called when the virtual listbox has hint information that we can
  597. pre-load. The hint is not a guaruntee that the items will be used
  598. or that items outside this range will be used.
  599. Author: EricDav
  600. ---------------------------------------------------------------------------*/
  601. STDMETHODIMP
  602. CBaseResultHandler::CacheHint
  603. (
  604. int nStartIndex,
  605. int nEndIndex
  606. )
  607. {
  608. return S_FALSE;
  609. }
  610. /*!--------------------------------------------------------------------------
  611. CBaseResultHandler::SortItems
  612. called when the Virutal listbox data needs to be sorted
  613. Author: EricDav
  614. ---------------------------------------------------------------------------*/
  615. STDMETHODIMP
  616. CBaseResultHandler::SortItems
  617. (
  618. int nColumn,
  619. DWORD dwSortOptions,
  620. LPARAM lUserParam
  621. )
  622. {
  623. return S_FALSE;
  624. }
  625. // task pad functions
  626. /*!--------------------------------------------------------------------------
  627. CBaseResultHandler::TaskPadNotify
  628. -
  629. Author: EricDav
  630. ---------------------------------------------------------------------------*/
  631. STDMETHODIMP
  632. CBaseResultHandler::TaskPadNotify
  633. (
  634. ITFSComponent * pComponent,
  635. MMC_COOKIE cookie,
  636. LPDATAOBJECT pDataObject,
  637. VARIANT * arg,
  638. VARIANT * param
  639. )
  640. {
  641. return S_FALSE;
  642. }
  643. /*!--------------------------------------------------------------------------
  644. CBaseResultHandler::EnumTasks
  645. -
  646. Author: EricDav
  647. ---------------------------------------------------------------------------*/
  648. STDMETHODIMP
  649. CBaseResultHandler::EnumTasks
  650. (
  651. ITFSComponent * pComponent,
  652. MMC_COOKIE cookie,
  653. LPDATAOBJECT pDataObject,
  654. LPOLESTR pszTaskGroup,
  655. IEnumTASK ** ppEnumTask
  656. )
  657. {
  658. return S_FALSE;
  659. }
  660. /*!--------------------------------------------------------------------------
  661. CBaseResultHandler::TaskPadGetTitle
  662. -
  663. Author: EricDav
  664. ---------------------------------------------------------------------------*/
  665. STDMETHODIMP
  666. CBaseResultHandler::TaskPadGetTitle
  667. (
  668. ITFSComponent * pComponent,
  669. MMC_COOKIE cookie,
  670. LPOLESTR pszGroup,
  671. LPOLESTR * ppszTitle
  672. )
  673. {
  674. return S_FALSE;
  675. }
  676. /*!--------------------------------------------------------------------------
  677. CBaseResultHandler::TaskPadGetBackground
  678. -
  679. Author: EricDav
  680. ---------------------------------------------------------------------------*/
  681. STDMETHODIMP
  682. CBaseResultHandler::TaskPadGetBackground
  683. (
  684. ITFSComponent * pComponent,
  685. MMC_COOKIE cookie,
  686. LPOLESTR pszGroup,
  687. MMC_TASK_DISPLAY_OBJECT * pTDO
  688. )
  689. {
  690. return S_FALSE;
  691. }
  692. /*!--------------------------------------------------------------------------
  693. CBaseResultHandler::TaskPadGetDescriptiveText
  694. -
  695. Author: EricDav
  696. ---------------------------------------------------------------------------*/
  697. STDMETHODIMP
  698. CBaseResultHandler::TaskPadGetDescriptiveText
  699. (
  700. ITFSComponent * pComponent,
  701. MMC_COOKIE cookie,
  702. LPOLESTR pszGroup,
  703. LPOLESTR * pszDescriptiveText
  704. )
  705. {
  706. return S_FALSE;
  707. }
  708. /*!--------------------------------------------------------------------------
  709. CBaseResultHandler::HasPropertyPages
  710. Implementation of ITFSResultHandler::HasPropertyPages
  711. Author: KennT
  712. ---------------------------------------------------------------------------*/
  713. STDMETHODIMP
  714. CBaseResultHandler::HasPropertyPages
  715. (
  716. ITFSComponent * pComponent,
  717. MMC_COOKIE cookie,
  718. LPDATAOBJECT pDataObject
  719. )
  720. {
  721. return S_FALSE;
  722. }
  723. /*!--------------------------------------------------------------------------
  724. CBaseResultHandler::CreatePropertyPages
  725. Implementation of ITFSResultHandler::CreatePropertyPages
  726. Author: KennT
  727. ---------------------------------------------------------------------------*/
  728. STDMETHODIMP
  729. CBaseResultHandler::CreatePropertyPages
  730. (
  731. ITFSComponent * pComponent,
  732. MMC_COOKIE cookie,
  733. LPPROPERTYSHEETCALLBACK lpProvider,
  734. LPDATAOBJECT pDataObject,
  735. LONG_PTR handle
  736. )
  737. {
  738. return S_FALSE;
  739. }
  740. /*!--------------------------------------------------------------------------
  741. CBaseResultHandler::AddMenuItems
  742. Implementation of ITFSResultHandler::AddMenuItems
  743. Author: KennT
  744. ---------------------------------------------------------------------------*/
  745. STDMETHODIMP
  746. CBaseResultHandler::AddMenuItems
  747. (
  748. ITFSComponent * pComponent,
  749. MMC_COOKIE cookie,
  750. LPDATAOBJECT pDataObject,
  751. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  752. long * pInsertionAllowed
  753. )
  754. {
  755. return S_FALSE;
  756. }
  757. /*!--------------------------------------------------------------------------
  758. CBaseResultHandler::Command
  759. Implementation of ITFSResultHandler::Command
  760. Author: KennT
  761. ---------------------------------------------------------------------------*/
  762. STDMETHODIMP
  763. CBaseResultHandler::Command
  764. (
  765. ITFSComponent * pComponent,
  766. MMC_COOKIE cookie,
  767. int nCommandID,
  768. LPDATAOBJECT pDataObject
  769. )
  770. {
  771. return S_FALSE;
  772. }
  773. /*!--------------------------------------------------------------------------
  774. CBaseResultHandler::OnCreateControlbars
  775. Implementation of ITFSResultHandler::OnCreateControlbars
  776. Author: KennT
  777. ---------------------------------------------------------------------------*/
  778. STDMETHODIMP
  779. CBaseResultHandler::OnCreateControlbars
  780. (
  781. ITFSComponent * pComponent,
  782. LPCONTROLBAR pControlBar
  783. )
  784. {
  785. return S_FALSE;
  786. }
  787. /*!--------------------------------------------------------------------------
  788. CBaseResultHandler::ControlbarNotify
  789. Implementation of ITFSResultHandler::ControlbarNotify
  790. Author: KennT
  791. ---------------------------------------------------------------------------*/
  792. STDMETHODIMP
  793. CBaseResultHandler::ControlbarNotify
  794. (
  795. ITFSComponent * pComponent,
  796. MMC_NOTIFY_TYPE event,
  797. LPARAM arg,
  798. LPARAM param
  799. )
  800. {
  801. return S_FALSE;
  802. }
  803. /*!--------------------------------------------------------------------------
  804. CBaseResultHandler::UserResultNotify
  805. Implememntation of ITFSNodeHandler::UserResultNotify
  806. Author: KennT
  807. ---------------------------------------------------------------------------*/
  808. STDMETHODIMP
  809. CBaseResultHandler::UserResultNotify
  810. (
  811. ITFSNode * pNode,
  812. LPARAM dwParam1,
  813. LPARAM dwParam2
  814. )
  815. {
  816. return S_FALSE;
  817. }
  818. /*!--------------------------------------------------------------------------
  819. CBaseResultHandler::OnCreateDataObject
  820. -
  821. Author: KennT
  822. ---------------------------------------------------------------------------*/
  823. STDMETHODIMP CBaseResultHandler::OnCreateDataObject(ITFSComponent *pComponent, MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  824. {
  825. // this relies on the ComponentData to do this work
  826. return S_FALSE;
  827. }
  828. /*---------------------------------------------------------------------------
  829. CBaseResultHandler Notifications
  830. ---------------------------------------------------------------------------*/
  831. HRESULT CBaseResultHandler::OnResultPropertyChange(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM param)
  832. {
  833. Trace0("IComponent::Notify(MMCN_PROPERTY_CHANGE) received\n");
  834. return S_FALSE;
  835. }
  836. /*!--------------------------------------------------------------------------
  837. CBaseResultHandler::OnResultUpdateView
  838. Implementation of ITFSResultHandler::OnResultUpdateView
  839. Author: EricDav
  840. ---------------------------------------------------------------------------*/
  841. HRESULT CBaseResultHandler::OnResultUpdateView
  842. (
  843. ITFSComponent *pComponent,
  844. LPDATAOBJECT pDataObject,
  845. LPARAM data,
  846. LPARAM hint
  847. )
  848. {
  849. SPITFSNode spSelectedNode;
  850. pComponent->GetSelectedNode(&spSelectedNode);
  851. if (hint == RESULT_PANE_DELETE_ALL)
  852. {
  853. if (spSelectedNode == NULL)
  854. return S_OK; // no selection for our IComponentData
  855. //
  856. // data contains the container whose result pane has to be refreshed
  857. //
  858. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  859. Assert(pNode != NULL);
  860. //
  861. // do it only if selected, if not, reselecting will do a delete/enumeration
  862. //
  863. if (spSelectedNode == pNode && !m_fMessageView)
  864. {
  865. SPIResultData spResultData;
  866. pComponent->GetResultData(&spResultData);
  867. Assert(spResultData != NULL);
  868. spResultData->DeleteAllRsltItems();
  869. }
  870. }
  871. else
  872. if (hint == RESULT_PANE_ADD_ALL)
  873. {
  874. if (spSelectedNode == NULL)
  875. return S_OK; // no selection for our IComponentData
  876. //
  877. // data contains the container whose result pane has to be refreshed
  878. //
  879. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  880. Assert(pNode != NULL);
  881. //
  882. // do it only if selected, if not, reselecting will do a delete/enumeration
  883. //
  884. if (spSelectedNode == pNode)
  885. {
  886. SPIResultData spResultData;
  887. pComponent->GetResultData(&spResultData);
  888. Assert(spResultData != NULL);
  889. //
  890. // update all the nodes in the result pane
  891. //
  892. SPITFSNodeEnum spNodeEnum;
  893. ITFSNode * pCurrentNode;
  894. ULONG nNumReturned = 0;
  895. pNode->GetEnum(&spNodeEnum);
  896. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  897. while (nNumReturned)
  898. {
  899. // All containers go into the scope pane and automatically get
  900. // put into the result pane for us by the MMC
  901. //
  902. if (!pCurrentNode->IsContainer())
  903. {
  904. AddResultPaneItem(pComponent, pCurrentNode);
  905. }
  906. pCurrentNode->Release();
  907. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  908. }
  909. }
  910. }
  911. else
  912. if (hint == RESULT_PANE_REPAINT)
  913. {
  914. if (spSelectedNode == NULL)
  915. return S_OK; // no selection for our IComponentData
  916. //
  917. // data contains the container whose result pane has to be refreshed
  918. //
  919. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  920. //if (pNode == NULL)
  921. // pContainer = m_pSelectedNode; // passing NULL means apply to the current selection
  922. //
  923. // update all the nodes in the result pane
  924. //
  925. SPITFSNodeEnum spNodeEnum;
  926. ITFSNode * pCurrentNode;
  927. ULONG nNumReturned = 0;
  928. pNode->GetEnum(&spNodeEnum);
  929. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  930. while (nNumReturned)
  931. {
  932. // All containers go into the scope pane and automatically get
  933. // put into the result pane for us by the MMC
  934. //
  935. if (!pCurrentNode->IsContainer())
  936. {
  937. ChangeResultPaneItem(pComponent, pCurrentNode, RESULT_PANE_CHANGE_ITEM);
  938. }
  939. pCurrentNode->Release();
  940. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  941. }
  942. }
  943. else
  944. if ( (hint == RESULT_PANE_ADD_ITEM) || (hint == RESULT_PANE_DELETE_ITEM) || (hint & RESULT_PANE_CHANGE_ITEM))
  945. {
  946. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  947. Assert(pNode != NULL);
  948. //
  949. // consider only if the parent is selected, otherwise will enumerate later when selected
  950. //
  951. SPITFSNode spParentNode;
  952. pNode->GetParent(&spParentNode);
  953. if (spSelectedNode == spParentNode)
  954. {
  955. if (hint & RESULT_PANE_CHANGE_ITEM)
  956. {
  957. ChangeResultPaneItem(pComponent, pNode, hint);
  958. }
  959. else if ( hint == RESULT_PANE_ADD_ITEM)
  960. {
  961. AddResultPaneItem(pComponent, pNode);
  962. }
  963. else if ( hint == RESULT_PANE_DELETE_ITEM)
  964. {
  965. DeleteResultPaneItem(pComponent, pNode);
  966. }
  967. }
  968. }
  969. else
  970. if ( hint == RESULT_PANE_SET_VIRTUAL_LB_SIZE )
  971. {
  972. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  973. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  974. if (pNode == spSelectedNode)
  975. {
  976. SetVirtualLbSize(pComponent, data);
  977. }
  978. }
  979. else
  980. if ( hint == RESULT_PANE_CLEAR_VIRTUAL_LB )
  981. {
  982. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  983. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  984. if (pNode == spSelectedNode)
  985. {
  986. ClearVirtualLb(pComponent, data);
  987. }
  988. }
  989. else
  990. if ( hint == RESULT_PANE_EXPAND )
  991. {
  992. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  993. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  994. SPIConsole spConsole;
  995. pComponent->GetConsole(&spConsole);
  996. spConsole->Expand(pNode->GetData(TFS_DATA_SCOPEID), (BOOL)data);
  997. }
  998. else
  999. if (hint == RESULT_PANE_SHOW_MESSAGE)
  1000. {
  1001. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  1002. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  1003. BOOL fOldMessageView = (BOOL) data;
  1004. //
  1005. // do it only if selected
  1006. //
  1007. if (spSelectedNode == pNode)
  1008. {
  1009. if (!fOldMessageView)
  1010. {
  1011. SPIConsole spConsole;
  1012. pComponent->GetConsole(&spConsole);
  1013. spConsole->SelectScopeItem(pNode->GetData(TFS_DATA_SCOPEID));
  1014. }
  1015. else
  1016. {
  1017. ShowResultMessage(pComponent, spInternal->m_cookie, NULL, NULL);
  1018. }
  1019. }
  1020. }
  1021. else
  1022. if (hint == RESULT_PANE_CLEAR_MESSAGE)
  1023. {
  1024. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  1025. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  1026. BOOL fOldMessageView = (BOOL) data;
  1027. //
  1028. // do it only if selected
  1029. //
  1030. if (spSelectedNode == pNode)
  1031. {
  1032. if (fOldMessageView)
  1033. {
  1034. SPIConsole spConsole;
  1035. pComponent->GetConsole(&spConsole);
  1036. spConsole->SelectScopeItem(pNode->GetData(TFS_DATA_SCOPEID));
  1037. }
  1038. }
  1039. }
  1040. // else if
  1041. return hrOK;
  1042. }
  1043. /*!--------------------------------------------------------------------------
  1044. CBaseResultHandler::ChangeResultPaneItem
  1045. Implementation of ChangeResultPaneItem
  1046. Author: EricDav
  1047. ---------------------------------------------------------------------------*/
  1048. HRESULT
  1049. CBaseResultHandler::ChangeResultPaneItem
  1050. (
  1051. ITFSComponent * pComponent,
  1052. ITFSNode * pNode,
  1053. LPARAM changeMask
  1054. )
  1055. {
  1056. Assert(changeMask & RESULT_PANE_CHANGE_ITEM);
  1057. Assert(pNode != NULL);
  1058. HRESULTITEM itemID;
  1059. HRESULT hr = hrOK;
  1060. SPIResultData pResultData;
  1061. CORg ( pComponent->GetResultData(&pResultData) );
  1062. CORg ( pResultData->FindItemByLParam(static_cast<LPARAM>(pNode->GetData(TFS_DATA_COOKIE)), &itemID) );
  1063. RESULTDATAITEM resultItem;
  1064. ZeroMemory(&resultItem, sizeof(RESULTDATAITEM));
  1065. resultItem.itemID = itemID;
  1066. if (changeMask & RESULT_PANE_CHANGE_ITEM_DATA)
  1067. {
  1068. resultItem.mask |= RDI_STR;
  1069. resultItem.str = MMC_CALLBACK;
  1070. }
  1071. if (changeMask & RESULT_PANE_CHANGE_ITEM_ICON)
  1072. {
  1073. resultItem.mask |= RDI_IMAGE;
  1074. resultItem.nImage = (int)pNode->GetData(TFS_DATA_IMAGEINDEX);
  1075. }
  1076. CORg ( pResultData->SetItem(&resultItem) );
  1077. CORg ( pResultData->UpdateItem(itemID) );
  1078. Error:
  1079. return hr;
  1080. }
  1081. /*!--------------------------------------------------------------------------
  1082. CBaseResultHandler::AddResultPaneItem
  1083. Implementation of AddResultPaneItem
  1084. Author: EricDav
  1085. ---------------------------------------------------------------------------*/
  1086. HRESULT
  1087. CBaseResultHandler::AddResultPaneItem
  1088. (
  1089. ITFSComponent * pComponent,
  1090. ITFSNode * pNode
  1091. )
  1092. {
  1093. Assert(pNode != NULL);
  1094. RESULTDATAITEM dataitemResult;
  1095. HRESULT hr = hrOK;
  1096. SPIResultData pResultData;
  1097. CORg ( pComponent->GetResultData(&pResultData) );
  1098. ZeroMemory(&dataitemResult, sizeof(dataitemResult));
  1099. dataitemResult.mask = RDI_STR | RDI_IMAGE | RDI_PARAM;
  1100. dataitemResult.str = MMC_CALLBACK;
  1101. dataitemResult.mask |= SDI_IMAGE;
  1102. dataitemResult.nImage = (int)pNode->GetData(TFS_DATA_IMAGEINDEX);
  1103. dataitemResult.lParam = static_cast<LPARAM>(pNode->GetData(TFS_DATA_COOKIE));
  1104. CORg ( pResultData->InsertItem(&dataitemResult) );
  1105. Error:
  1106. return hr;
  1107. }
  1108. /*!--------------------------------------------------------------------------
  1109. CBaseResultHandler::DeleteResultPaneItem
  1110. Implementation of DeleteResultPaneItem
  1111. Author: EricDav
  1112. ---------------------------------------------------------------------------*/
  1113. HRESULT
  1114. CBaseResultHandler::DeleteResultPaneItem
  1115. (
  1116. ITFSComponent * pComponent,
  1117. ITFSNode * pNode
  1118. )
  1119. {
  1120. Assert(pNode != NULL);
  1121. HRESULT hr = hrOK;
  1122. HRESULTITEM itemID;
  1123. SPIResultData pResultData;
  1124. CORg ( pComponent->GetResultData(&pResultData) );
  1125. CORg ( pResultData->FindItemByLParam(static_cast<LPARAM>(pNode->GetData(TFS_DATA_COOKIE)), &itemID) );
  1126. CORg ( pResultData->DeleteItem(itemID, 0 /* all cols */) );
  1127. Error:
  1128. return hr;
  1129. }
  1130. /*!--------------------------------------------------------------------------
  1131. CBaseResultHandler::SetVirtualLbSize
  1132. Sets the virtual listbox count. Over-ride this if you need to
  1133. specify and options.
  1134. Author: EricDav
  1135. ---------------------------------------------------------------------------*/
  1136. HRESULT
  1137. CBaseResultHandler::SetVirtualLbSize
  1138. (
  1139. ITFSComponent * pComponent,
  1140. LONG_PTR data
  1141. )
  1142. {
  1143. HRESULT hr = hrOK;
  1144. SPIResultData spResultData;
  1145. CORg (pComponent->GetResultData(&spResultData));
  1146. CORg (spResultData->SetItemCount((int) data, MMCLV_UPDATE_NOINVALIDATEALL));
  1147. Error:
  1148. return hr;
  1149. }
  1150. /*!--------------------------------------------------------------------------
  1151. CBaseResultHandler::ClearVirtualLb
  1152. Sets the virtual listbox count. Over-ride this if you need to
  1153. specify and options.
  1154. Author: EricDav
  1155. ---------------------------------------------------------------------------*/
  1156. HRESULT
  1157. CBaseResultHandler::ClearVirtualLb
  1158. (
  1159. ITFSComponent * pComponent,
  1160. LONG_PTR data
  1161. )
  1162. {
  1163. HRESULT hr = hrOK;
  1164. SPIResultData spResultData;
  1165. CORg (pComponent->GetResultData(&spResultData));
  1166. CORg (spResultData->SetItemCount((int) data, 0));
  1167. Error:
  1168. return hr;
  1169. }
  1170. /*!--------------------------------------------------------------------------
  1171. CBaseResultHandler::OnResultActivate
  1172. -
  1173. Author: KennT
  1174. ---------------------------------------------------------------------------*/
  1175. HRESULT CBaseResultHandler::OnResultActivate(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM param)
  1176. {
  1177. Trace0("IComponent::Notify(MMCN_ACTIVATE) received\n");
  1178. return S_FALSE;
  1179. }
  1180. /*!--------------------------------------------------------------------------
  1181. CBaseResultHandler::OnResultItemClkOrDblClk
  1182. -
  1183. Author: KennT
  1184. ---------------------------------------------------------------------------*/
  1185. HRESULT CBaseResultHandler::OnResultItemClkOrDblClk(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM param, BOOL bDoubleClick)
  1186. {
  1187. if (!bDoubleClick)
  1188. Trace0("IComponent::Notify(MMCN_CLK) received\n");
  1189. else
  1190. Trace0("IComponent::Notify(MMCN_DBLCLK) received\n");
  1191. // return false so that MMC does the default behavior (open the node);
  1192. return S_FALSE;
  1193. }
  1194. /*!--------------------------------------------------------------------------
  1195. CBaseResultHandler::OnResultShow
  1196. -
  1197. Author: KennT
  1198. ---------------------------------------------------------------------------*/
  1199. HRESULT CBaseResultHandler::OnResultShow(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1200. {
  1201. // Note - arg is TRUE when it is time to enumerate
  1202. if (arg == TRUE)
  1203. {
  1204. // show the result view message if there is one
  1205. ShowResultMessage(pComponent, cookie, arg, lParam);
  1206. // Show the headers for this nodetype
  1207. LoadColumns(pComponent, cookie, arg, lParam);
  1208. EnumerateResultPane(pComponent, cookie, arg, lParam);
  1209. SortColumns(pComponent);
  1210. SPITFSNode spNode;
  1211. m_spResultNodeMgr->FindNode(cookie, &spNode);
  1212. pComponent->SetSelectedNode(spNode);
  1213. }
  1214. else
  1215. {
  1216. SaveColumns(pComponent, cookie, arg, lParam);
  1217. pComponent->SetSelectedNode(NULL);
  1218. // Free data associated with the result pane items, because
  1219. // your node is no longer being displayed.
  1220. // Note: The console will remove the items from the result pane
  1221. }
  1222. return hrOK;
  1223. }
  1224. /*!--------------------------------------------------------------------------
  1225. CBaseResultHandler::OnResultColumnClick
  1226. -
  1227. Author: KennT
  1228. ---------------------------------------------------------------------------*/
  1229. HRESULT CBaseResultHandler::OnResultColumnClick(ITFSComponent *pComponent, LPARAM iColumn, BOOL fAscending)
  1230. {
  1231. return S_FALSE;
  1232. }
  1233. /*!--------------------------------------------------------------------------
  1234. CBaseResultHandler::OnResultColumnsChanged
  1235. -
  1236. Author: KennT
  1237. ---------------------------------------------------------------------------*/
  1238. HRESULT CBaseResultHandler::OnResultColumnsChanged(ITFSComponent *, LPDATAOBJECT, MMC_VISIBLE_COLUMNS *)
  1239. {
  1240. return S_FALSE;
  1241. }
  1242. /*!--------------------------------------------------------------------------
  1243. CBaseResultHandler::ShowResultMessage
  1244. -
  1245. Author: EricDav
  1246. ---------------------------------------------------------------------------*/
  1247. HRESULT CBaseResultHandler::ShowResultMessage(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1248. {
  1249. HRESULT hr = hrOK;
  1250. SPIMessageView spMessageView;
  1251. SPIUnknown spUnknown;
  1252. SPIConsole spConsole;
  1253. LPOLESTR pText = NULL;
  1254. // put up our message text
  1255. if (m_fMessageView)
  1256. {
  1257. if (pComponent)
  1258. {
  1259. CORg ( pComponent->GetConsole(&spConsole) );
  1260. CORg ( spConsole->QueryResultView(&spUnknown) );
  1261. CORg ( spMessageView.HrQuery(spUnknown) );
  1262. }
  1263. // set the title text
  1264. pText = (LPOLESTR)CoTaskMemAlloc (sizeof(OLECHAR) * (m_strMessageTitle.GetLength() + 1));
  1265. if (pText)
  1266. {
  1267. lstrcpy (pText, m_strMessageTitle);
  1268. CORg(spMessageView->SetTitleText(pText));
  1269. // bugid:148215 vivekk
  1270. CoTaskMemFree(pText);
  1271. }
  1272. // set the body text
  1273. pText = (LPOLESTR)CoTaskMemAlloc (sizeof(OLECHAR) * (m_strMessageBody.GetLength() + 1));
  1274. if (pText)
  1275. {
  1276. lstrcpy (pText, m_strMessageBody);
  1277. CORg(spMessageView->SetBodyText(pText));
  1278. // bugid:148215 vivekk
  1279. CoTaskMemFree(pText);
  1280. }
  1281. // set the icon
  1282. CORg(spMessageView->SetIcon(m_lMessageIcon));
  1283. COM_PROTECT_ERROR_LABEL;
  1284. }
  1285. return hr;
  1286. }
  1287. /*!--------------------------------------------------------------------------
  1288. CBaseResultHandler::ShowMessage
  1289. -
  1290. Author: EricDav
  1291. ---------------------------------------------------------------------------*/
  1292. HRESULT CBaseResultHandler::ShowMessage(ITFSNode * pNode, LPCTSTR pszTitle, LPCTSTR pszBody, IconIdentifier lIcon)
  1293. {
  1294. HRESULT hr = hrOK;
  1295. SPIComponentData spCompData;
  1296. SPIConsole spConsole;
  1297. SPIDataObject spDataObject;
  1298. IDataObject * pDataObject;
  1299. BOOL fOldMessageView;
  1300. m_strMessageTitle = pszTitle;
  1301. m_strMessageBody = pszBody;
  1302. m_lMessageIcon = lIcon;
  1303. fOldMessageView = m_fMessageView;
  1304. m_fMessageView = TRUE;
  1305. // tell the views to update themselves here
  1306. m_spResultNodeMgr->GetComponentData(&spCompData);
  1307. CORg ( spCompData->QueryDataObject((MMC_COOKIE) pNode, CCT_SCOPE, &pDataObject) );
  1308. spDataObject = pDataObject;
  1309. CORg ( m_spResultNodeMgr->GetConsole(&spConsole) );
  1310. CORg ( spConsole->UpdateAllViews(pDataObject, (LPARAM) fOldMessageView, RESULT_PANE_SHOW_MESSAGE) );
  1311. COM_PROTECT_ERROR_LABEL;
  1312. return hr;
  1313. }
  1314. /*!--------------------------------------------------------------------------
  1315. CBaseResultHandler::ClearMessage
  1316. -
  1317. Author: EricDav
  1318. ---------------------------------------------------------------------------*/
  1319. HRESULT CBaseResultHandler::ClearMessage(ITFSNode * pNode)
  1320. {
  1321. HRESULT hr = hrOK;
  1322. SPIComponentData spCompData;
  1323. SPIConsole spConsole;
  1324. SPIDataObject spDataObject;
  1325. IDataObject * pDataObject;
  1326. BOOL fOldMessageView;
  1327. fOldMessageView = m_fMessageView;
  1328. m_fMessageView = FALSE;
  1329. // tell the views to update themselves here
  1330. m_spResultNodeMgr->GetComponentData(&spCompData);
  1331. CORg ( spCompData->QueryDataObject((MMC_COOKIE) pNode, CCT_SCOPE, &pDataObject) );
  1332. spDataObject = pDataObject;
  1333. CORg ( m_spResultNodeMgr->GetConsole(&spConsole) );
  1334. CORg ( spConsole->UpdateAllViews(pDataObject, (LPARAM) fOldMessageView, RESULT_PANE_CLEAR_MESSAGE) );
  1335. COM_PROTECT_ERROR_LABEL;
  1336. return hr;
  1337. }
  1338. /*!--------------------------------------------------------------------------
  1339. CBaseResultHandler::LoadColumns
  1340. -
  1341. Author: EricDav
  1342. ---------------------------------------------------------------------------*/
  1343. HRESULT CBaseResultHandler::LoadColumns(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1344. {
  1345. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1346. SPIHeaderCtrl spHeaderCtrl;
  1347. pComponent->GetHeaderCtrl(&spHeaderCtrl);
  1348. CString str;
  1349. int i = 0;
  1350. if (!m_pColumnStringIDs)
  1351. return hrOK;
  1352. if (!m_fMessageView)
  1353. {
  1354. while (TRUE)
  1355. {
  1356. int nColumnWidth = AUTO_WIDTH;
  1357. if ( 0 == m_pColumnStringIDs[i] )
  1358. break;
  1359. str.LoadString(m_pColumnStringIDs[i]);
  1360. if (m_pColumnWidths)
  1361. nColumnWidth = m_pColumnWidths[i];
  1362. spHeaderCtrl->InsertColumn(i,
  1363. const_cast<LPTSTR>((LPCWSTR)str),
  1364. m_nColumnFormat,
  1365. nColumnWidth);
  1366. i++;
  1367. }
  1368. }
  1369. return hrOK;
  1370. }
  1371. /*!--------------------------------------------------------------------------
  1372. CBaseResultHandler::SaveColumns
  1373. -
  1374. Author: KennT
  1375. ---------------------------------------------------------------------------*/
  1376. HRESULT CBaseResultHandler::SaveColumns(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1377. {
  1378. return S_FALSE;
  1379. }
  1380. /*!--------------------------------------------------------------------------
  1381. CBaseResultHandler::SortColumns
  1382. -
  1383. Author: KennT
  1384. ---------------------------------------------------------------------------*/
  1385. HRESULT CBaseResultHandler::SortColumns(ITFSComponent *pComponent)
  1386. {
  1387. return S_FALSE;
  1388. }
  1389. /*!--------------------------------------------------------------------------
  1390. CBaseResultHandler::EnumerateResultPane
  1391. -
  1392. Author: EricDav
  1393. ---------------------------------------------------------------------------*/
  1394. HRESULT CBaseResultHandler::EnumerateResultPane(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1395. {
  1396. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1397. SPITFSNode spContainer;
  1398. m_spResultNodeMgr->FindNode(cookie, &spContainer);
  1399. //
  1400. // Walk the list of children to see if there's anything
  1401. // to put in the result pane
  1402. //
  1403. SPITFSNodeEnum spNodeEnum;
  1404. ITFSNode * pCurrentNode;
  1405. ULONG nNumReturned = 0;
  1406. spContainer->GetEnum(&spNodeEnum);
  1407. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  1408. while (nNumReturned)
  1409. {
  1410. //
  1411. // All containers go into the scope pane and automatically get
  1412. // put into the result pane for us by the MMC
  1413. //
  1414. if (!pCurrentNode->IsContainer() && pCurrentNode->IsVisible())
  1415. {
  1416. AddResultPaneItem(pComponent, pCurrentNode);
  1417. }
  1418. pCurrentNode->Release();
  1419. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  1420. }
  1421. return hrOK;
  1422. }
  1423. /*!--------------------------------------------------------------------------
  1424. CBaseResultHandler::OnResultSelect
  1425. -
  1426. Author: EricDav
  1427. ---------------------------------------------------------------------------*/
  1428. HRESULT CBaseResultHandler::OnResultSelect(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1429. {
  1430. HRESULT hr = hrOK;
  1431. SPIConsoleVerb spConsoleVerb;
  1432. CORg (pComponent->GetConsoleVerb(&spConsoleVerb));
  1433. // Default is to turn everything off
  1434. spConsoleVerb->SetVerbState(MMC_VERB_OPEN, HIDDEN, TRUE);
  1435. spConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, TRUE);
  1436. spConsoleVerb->SetVerbState(MMC_VERB_PASTE, HIDDEN, TRUE);
  1437. spConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, TRUE);
  1438. spConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  1439. spConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, TRUE);
  1440. spConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, TRUE);
  1441. spConsoleVerb->SetVerbState(MMC_VERB_PRINT, HIDDEN, TRUE);
  1442. Error:
  1443. return hr;
  1444. }
  1445. /*!--------------------------------------------------------------------------
  1446. CBaseResultHandler::OnResultInitOcx
  1447. -
  1448. Author: EricDav
  1449. ---------------------------------------------------------------------------*/
  1450. HRESULT CBaseResultHandler::OnResultInitOcx(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1451. {
  1452. // arg - not used
  1453. // param - contains IUnknown to the OCX
  1454. return S_FALSE;
  1455. }
  1456. /*!--------------------------------------------------------------------------
  1457. CBaseResultHandler::FIsTaskpadPreferred
  1458. -
  1459. Author: EricDav
  1460. ---------------------------------------------------------------------------*/
  1461. HRESULT CBaseResultHandler::FIsTaskpadPreferred(ITFSComponent *pComponent)
  1462. {
  1463. HRESULT hr = hrOK;
  1464. SPIConsole spConsole;
  1465. pComponent->GetConsole(&spConsole);
  1466. hr = spConsole->IsTaskpadViewPreferred();
  1467. //Error:
  1468. return hr;
  1469. }
  1470. /*!--------------------------------------------------------------------------
  1471. CBaseResultHandler::DoTaskpadResultSelect
  1472. Handlers with taskpads should override the OnResultSelect and call
  1473. this to handle setting of the selected node.
  1474. Author: EricDav
  1475. ---------------------------------------------------------------------------*/
  1476. HRESULT CBaseResultHandler::DoTaskpadResultSelect(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam, BOOL bTaskPadView)
  1477. {
  1478. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1479. SPITFSNode spNode, spSelectedNode;
  1480. HRESULT hr = hrOK;
  1481. // if this node is being selected then set the selected node.
  1482. // this node with a taskpad gets the MMCN_SHOW when the node is
  1483. // de-selected, so that will set the selected node to NULL.
  1484. if ( (HIWORD(arg) == TRUE) &&
  1485. bTaskPadView )
  1486. {
  1487. m_spResultNodeMgr->FindNode(cookie, &spNode);
  1488. pComponent->GetSelectedNode(&spSelectedNode);
  1489. // in the normal case MMC will call whichever node is selected to
  1490. // notify that is being de-selected. In this case our handler will
  1491. // set the selected node to NULL. If the selected node is not null then
  1492. // we are just being notified of something like a selection for a context
  1493. // menu...
  1494. if (!spSelectedNode)
  1495. pComponent->SetSelectedNode(spNode);
  1496. }
  1497. // call the base class to handle anything else
  1498. return hr;
  1499. }
  1500. /*!--------------------------------------------------------------------------
  1501. CBaseResultHandler::OnGetResultViewType
  1502. MMC calls this to get the result view information
  1503. Author: EricDav
  1504. ---------------------------------------------------------------------------*/
  1505. HRESULT CBaseResultHandler::OnGetResultViewType
  1506. (
  1507. ITFSComponent * pComponent,
  1508. MMC_COOKIE cookie,
  1509. LPOLESTR * ppViewType,
  1510. long * pViewOptions
  1511. )
  1512. {
  1513. HRESULT hr = S_FALSE;
  1514. //
  1515. // use the MMC default result view if no message is specified.
  1516. // Multiple selection, or virtual listbox, override this function.
  1517. // See MMC sample code for example. The Message view uses an OCX...
  1518. //
  1519. if (m_fMessageView)
  1520. {
  1521. // create the message view thingie
  1522. *pViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  1523. LPOLESTR psz = NULL;
  1524. StringFromCLSID(CLSID_MessageView, &psz);
  1525. USES_CONVERSION;
  1526. if (psz != NULL)
  1527. {
  1528. *ppViewType = psz;
  1529. hr = S_OK;
  1530. }
  1531. }
  1532. return hr;
  1533. }
  1534. /*!--------------------------------------------------------------------------
  1535. CBaseResultHandler::GetVirtualString
  1536. called when the virtual listbox needs information on an index
  1537. Author: EricDav
  1538. ---------------------------------------------------------------------------*/
  1539. LPCWSTR CBaseResultHandler::GetVirtualString
  1540. (
  1541. int nIndex,
  1542. int nCol
  1543. )
  1544. {
  1545. return NULL;
  1546. }
  1547. /*!--------------------------------------------------------------------------
  1548. CBaseResultHandler::GetVirtualImage
  1549. called when the virtual listbox needs an image index for an item
  1550. Author: EricDav
  1551. ---------------------------------------------------------------------------*/
  1552. int CBaseResultHandler::GetVirtualImage
  1553. (
  1554. int nIndex
  1555. )
  1556. {
  1557. return 0;
  1558. }
  1559. HRESULT CBaseResultHandler::OnResultMinimize(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1560. {
  1561. Trace0("IComponent::Notify(MMCN_MINIMIZE) received\n");
  1562. return S_FALSE;
  1563. }
  1564. HRESULT CBaseResultHandler::OnResultDelete(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1565. {
  1566. Trace0("IComponent::Notify(MMCN_DELETE) received\n");
  1567. return S_FALSE;
  1568. }
  1569. HRESULT CBaseResultHandler::OnResultRename(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1570. {
  1571. Trace0("IComponent::Notify(MMCN_RENAME) received\n");
  1572. return S_FALSE;
  1573. }
  1574. HRESULT CBaseResultHandler::OnResultRefresh(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1575. {
  1576. Trace0("IComponent::Notify(MMCN_REFRESH) received\n");
  1577. return S_FALSE;
  1578. }
  1579. HRESULT CBaseResultHandler::OnResultContextHelp(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1580. {
  1581. Trace0("IComponent::Notify(MMCN_CONTEXTHELP) received\n");
  1582. return S_FALSE;
  1583. }
  1584. HRESULT CBaseResultHandler::OnResultQueryPaste(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1585. {
  1586. Trace0("IComponent::Notify(MMCN_QUERY_PASTE) received\n");
  1587. return S_FALSE;
  1588. }
  1589. HRESULT CBaseResultHandler::OnResultVerbCopy(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1590. {
  1591. Trace0("IComponent::Notify(MMCN_VERB_COPY) received\n");
  1592. return S_FALSE;
  1593. }
  1594. HRESULT CBaseResultHandler::OnResultVerbPaste(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1595. {
  1596. Trace0("IComponent::Notify(MMCN_VERB_PASTE) received\n");
  1597. return S_FALSE;
  1598. }
  1599. HRESULT CBaseResultHandler::OnResultVerbDelete(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1600. {
  1601. Trace0("IComponent::Notify(MMCN_VERB_DELETE) received\n");
  1602. return S_FALSE;
  1603. }
  1604. HRESULT CBaseResultHandler::OnResultVerbProperties(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1605. {
  1606. Trace0("IComponent::Notify(MMCN_VERB_PROPERTIES) received\n");
  1607. return S_FALSE;
  1608. }
  1609. HRESULT CBaseResultHandler::OnResultVerbRename(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1610. {
  1611. Trace0("IComponent::Notify(MMCN_VERB_RENAME) received\n");
  1612. return S_FALSE;
  1613. }
  1614. HRESULT CBaseResultHandler::OnResultVerbRefresh(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1615. {
  1616. Trace0("IComponent::Notify(MMCN_VERB_REFRESH) received\n");
  1617. return S_FALSE;
  1618. }
  1619. HRESULT CBaseResultHandler::OnResultVerbPrint(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1620. {
  1621. Trace0("IComponent::Notify(MMCN_VERB_PRINT) received\n");
  1622. return S_FALSE;
  1623. }
  1624. HRESULT CBaseResultHandler::OnResultRestoreView(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1625. {
  1626. Trace0("IComponent::Notify(MMCN_RESTORE_VIEW) received\n");
  1627. return S_FALSE;
  1628. }