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.

1935 lines
56 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. STDMETHODIMP_(int)
  581. CBaseResultHandler::CompareItems
  582. (
  583. ITFSComponent *pComponent,
  584. RDCOMPARE *prdc
  585. )
  586. {
  587. // See if IResultCompare is implemented and use it.
  588. return CompareItems( pComponent,
  589. prdc->prdch1->cookie,
  590. prdc->prdch2->cookie,
  591. prdc->nColumn );
  592. } // CBaseResultHandler::CompareItems()
  593. /*!--------------------------------------------------------------------------
  594. CBaseResultHandler::FindItem
  595. called when the Virutal listbox needs to find an item.
  596. Author: EricDav
  597. ---------------------------------------------------------------------------*/
  598. STDMETHODIMP
  599. CBaseResultHandler::FindItem
  600. (
  601. LPRESULTFINDINFO pFindInfo,
  602. int * pnFoundIndex
  603. )
  604. {
  605. return S_FALSE;
  606. }
  607. /*!--------------------------------------------------------------------------
  608. CBaseResultHandler::CacheHint
  609. called when the virtual listbox has hint information that we can
  610. pre-load. The hint is not a guaruntee that the items will be used
  611. or that items outside this range will be used.
  612. Author: EricDav
  613. ---------------------------------------------------------------------------*/
  614. STDMETHODIMP
  615. CBaseResultHandler::CacheHint
  616. (
  617. int nStartIndex,
  618. int nEndIndex
  619. )
  620. {
  621. return S_FALSE;
  622. }
  623. /*!--------------------------------------------------------------------------
  624. CBaseResultHandler::SortItems
  625. called when the Virutal listbox data needs to be sorted
  626. Author: EricDav
  627. ---------------------------------------------------------------------------*/
  628. STDMETHODIMP
  629. CBaseResultHandler::SortItems
  630. (
  631. int nColumn,
  632. DWORD dwSortOptions,
  633. LPARAM lUserParam
  634. )
  635. {
  636. return S_FALSE;
  637. }
  638. // task pad functions
  639. /*!--------------------------------------------------------------------------
  640. CBaseResultHandler::TaskPadNotify
  641. -
  642. Author: EricDav
  643. ---------------------------------------------------------------------------*/
  644. STDMETHODIMP
  645. CBaseResultHandler::TaskPadNotify
  646. (
  647. ITFSComponent * pComponent,
  648. MMC_COOKIE cookie,
  649. LPDATAOBJECT pDataObject,
  650. VARIANT * arg,
  651. VARIANT * param
  652. )
  653. {
  654. return S_FALSE;
  655. }
  656. /*!--------------------------------------------------------------------------
  657. CBaseResultHandler::EnumTasks
  658. -
  659. Author: EricDav
  660. ---------------------------------------------------------------------------*/
  661. STDMETHODIMP
  662. CBaseResultHandler::EnumTasks
  663. (
  664. ITFSComponent * pComponent,
  665. MMC_COOKIE cookie,
  666. LPDATAOBJECT pDataObject,
  667. LPOLESTR pszTaskGroup,
  668. IEnumTASK ** ppEnumTask
  669. )
  670. {
  671. return S_FALSE;
  672. }
  673. /*!--------------------------------------------------------------------------
  674. CBaseResultHandler::TaskPadGetTitle
  675. -
  676. Author: EricDav
  677. ---------------------------------------------------------------------------*/
  678. STDMETHODIMP
  679. CBaseResultHandler::TaskPadGetTitle
  680. (
  681. ITFSComponent * pComponent,
  682. MMC_COOKIE cookie,
  683. LPOLESTR pszGroup,
  684. LPOLESTR * ppszTitle
  685. )
  686. {
  687. return S_FALSE;
  688. }
  689. /*!--------------------------------------------------------------------------
  690. CBaseResultHandler::TaskPadGetBackground
  691. -
  692. Author: EricDav
  693. ---------------------------------------------------------------------------*/
  694. STDMETHODIMP
  695. CBaseResultHandler::TaskPadGetBackground
  696. (
  697. ITFSComponent * pComponent,
  698. MMC_COOKIE cookie,
  699. LPOLESTR pszGroup,
  700. MMC_TASK_DISPLAY_OBJECT * pTDO
  701. )
  702. {
  703. return S_FALSE;
  704. }
  705. /*!--------------------------------------------------------------------------
  706. CBaseResultHandler::TaskPadGetDescriptiveText
  707. -
  708. Author: EricDav
  709. ---------------------------------------------------------------------------*/
  710. STDMETHODIMP
  711. CBaseResultHandler::TaskPadGetDescriptiveText
  712. (
  713. ITFSComponent * pComponent,
  714. MMC_COOKIE cookie,
  715. LPOLESTR pszGroup,
  716. LPOLESTR * pszDescriptiveText
  717. )
  718. {
  719. return S_FALSE;
  720. }
  721. /*!--------------------------------------------------------------------------
  722. CBaseResultHandler::HasPropertyPages
  723. Implementation of ITFSResultHandler::HasPropertyPages
  724. Author: KennT
  725. ---------------------------------------------------------------------------*/
  726. STDMETHODIMP
  727. CBaseResultHandler::HasPropertyPages
  728. (
  729. ITFSComponent * pComponent,
  730. MMC_COOKIE cookie,
  731. LPDATAOBJECT pDataObject
  732. )
  733. {
  734. return S_FALSE;
  735. }
  736. /*!--------------------------------------------------------------------------
  737. CBaseResultHandler::CreatePropertyPages
  738. Implementation of ITFSResultHandler::CreatePropertyPages
  739. Author: KennT
  740. ---------------------------------------------------------------------------*/
  741. STDMETHODIMP
  742. CBaseResultHandler::CreatePropertyPages
  743. (
  744. ITFSComponent * pComponent,
  745. MMC_COOKIE cookie,
  746. LPPROPERTYSHEETCALLBACK lpProvider,
  747. LPDATAOBJECT pDataObject,
  748. LONG_PTR handle
  749. )
  750. {
  751. return S_FALSE;
  752. }
  753. /*!--------------------------------------------------------------------------
  754. CBaseResultHandler::AddMenuItems
  755. Implementation of ITFSResultHandler::AddMenuItems
  756. Author: KennT
  757. ---------------------------------------------------------------------------*/
  758. STDMETHODIMP
  759. CBaseResultHandler::AddMenuItems
  760. (
  761. ITFSComponent * pComponent,
  762. MMC_COOKIE cookie,
  763. LPDATAOBJECT pDataObject,
  764. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  765. long * pInsertionAllowed
  766. )
  767. {
  768. return S_FALSE;
  769. }
  770. /*!--------------------------------------------------------------------------
  771. CBaseResultHandler::Command
  772. Implementation of ITFSResultHandler::Command
  773. Author: KennT
  774. ---------------------------------------------------------------------------*/
  775. STDMETHODIMP
  776. CBaseResultHandler::Command
  777. (
  778. ITFSComponent * pComponent,
  779. MMC_COOKIE cookie,
  780. int nCommandID,
  781. LPDATAOBJECT pDataObject
  782. )
  783. {
  784. return S_FALSE;
  785. }
  786. /*!--------------------------------------------------------------------------
  787. CBaseResultHandler::OnCreateControlbars
  788. Implementation of ITFSResultHandler::OnCreateControlbars
  789. Author: KennT
  790. ---------------------------------------------------------------------------*/
  791. STDMETHODIMP
  792. CBaseResultHandler::OnCreateControlbars
  793. (
  794. ITFSComponent * pComponent,
  795. LPCONTROLBAR pControlBar
  796. )
  797. {
  798. return S_FALSE;
  799. }
  800. /*!--------------------------------------------------------------------------
  801. CBaseResultHandler::ControlbarNotify
  802. Implementation of ITFSResultHandler::ControlbarNotify
  803. Author: KennT
  804. ---------------------------------------------------------------------------*/
  805. STDMETHODIMP
  806. CBaseResultHandler::ControlbarNotify
  807. (
  808. ITFSComponent * pComponent,
  809. MMC_NOTIFY_TYPE event,
  810. LPARAM arg,
  811. LPARAM param
  812. )
  813. {
  814. return S_FALSE;
  815. }
  816. /*!--------------------------------------------------------------------------
  817. CBaseResultHandler::UserResultNotify
  818. Implememntation of ITFSNodeHandler::UserResultNotify
  819. Author: KennT
  820. ---------------------------------------------------------------------------*/
  821. STDMETHODIMP
  822. CBaseResultHandler::UserResultNotify
  823. (
  824. ITFSNode * pNode,
  825. LPARAM dwParam1,
  826. LPARAM dwParam2
  827. )
  828. {
  829. return S_FALSE;
  830. }
  831. /*!--------------------------------------------------------------------------
  832. CBaseResultHandler::OnCreateDataObject
  833. -
  834. Author: KennT
  835. ---------------------------------------------------------------------------*/
  836. STDMETHODIMP CBaseResultHandler::OnCreateDataObject(ITFSComponent *pComponent, MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  837. {
  838. // this relies on the ComponentData to do this work
  839. return S_FALSE;
  840. }
  841. /*---------------------------------------------------------------------------
  842. CBaseResultHandler Notifications
  843. ---------------------------------------------------------------------------*/
  844. HRESULT CBaseResultHandler::OnResultPropertyChange(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM param)
  845. {
  846. Trace0("IComponent::Notify(MMCN_PROPERTY_CHANGE) received\n");
  847. return S_FALSE;
  848. }
  849. /*!--------------------------------------------------------------------------
  850. CBaseResultHandler::OnResultUpdateView
  851. Implementation of ITFSResultHandler::OnResultUpdateView
  852. Author: EricDav
  853. ---------------------------------------------------------------------------*/
  854. HRESULT CBaseResultHandler::OnResultUpdateView
  855. (
  856. ITFSComponent *pComponent,
  857. LPDATAOBJECT pDataObject,
  858. LPARAM data,
  859. LPARAM hint
  860. )
  861. {
  862. SPITFSNode spSelectedNode;
  863. pComponent->GetSelectedNode(&spSelectedNode);
  864. if (hint == RESULT_PANE_DELETE_ALL)
  865. {
  866. if (spSelectedNode == NULL)
  867. return S_OK; // no selection for our IComponentData
  868. //
  869. // data contains the container whose result pane has to be refreshed
  870. //
  871. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  872. Assert(pNode != NULL);
  873. //
  874. // do it only if selected, if not, reselecting will do a delete/enumeration
  875. //
  876. if (spSelectedNode == pNode && !m_fMessageView)
  877. {
  878. SPIResultData spResultData;
  879. pComponent->GetResultData(&spResultData);
  880. Assert(spResultData != NULL);
  881. spResultData->DeleteAllRsltItems();
  882. }
  883. }
  884. else
  885. if (hint == RESULT_PANE_ADD_ALL)
  886. {
  887. if (spSelectedNode == NULL)
  888. return S_OK; // no selection for our IComponentData
  889. //
  890. // data contains the container whose result pane has to be refreshed
  891. //
  892. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  893. Assert(pNode != NULL);
  894. //
  895. // do it only if selected, if not, reselecting will do a delete/enumeration
  896. //
  897. if (spSelectedNode == pNode)
  898. {
  899. SPIResultData spResultData;
  900. pComponent->GetResultData(&spResultData);
  901. Assert(spResultData != NULL);
  902. //
  903. // update all the nodes in the result pane
  904. //
  905. SPITFSNodeEnum spNodeEnum;
  906. ITFSNode * pCurrentNode;
  907. ULONG nNumReturned = 0;
  908. pNode->GetEnum(&spNodeEnum);
  909. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  910. while (nNumReturned)
  911. {
  912. // All containers go into the scope pane and automatically get
  913. // put into the result pane for us by the MMC
  914. //
  915. if (!pCurrentNode->IsContainer())
  916. {
  917. AddResultPaneItem(pComponent, pCurrentNode);
  918. }
  919. pCurrentNode->Release();
  920. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  921. }
  922. }
  923. }
  924. else
  925. if (hint == RESULT_PANE_REPAINT)
  926. {
  927. if (spSelectedNode == NULL)
  928. return S_OK; // no selection for our IComponentData
  929. //
  930. // data contains the container whose result pane has to be refreshed
  931. //
  932. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  933. //if (pNode == NULL)
  934. // pContainer = m_pSelectedNode; // passing NULL means apply to the current selection
  935. //
  936. // update all the nodes in the result pane
  937. //
  938. SPITFSNodeEnum spNodeEnum;
  939. ITFSNode * pCurrentNode;
  940. ULONG nNumReturned = 0;
  941. pNode->GetEnum(&spNodeEnum);
  942. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  943. while (nNumReturned)
  944. {
  945. // All containers go into the scope pane and automatically get
  946. // put into the result pane for us by the MMC
  947. //
  948. if (!pCurrentNode->IsContainer())
  949. {
  950. ChangeResultPaneItem(pComponent, pCurrentNode, RESULT_PANE_CHANGE_ITEM);
  951. }
  952. pCurrentNode->Release();
  953. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  954. }
  955. }
  956. else
  957. if ( (hint == RESULT_PANE_ADD_ITEM) || (hint == RESULT_PANE_DELETE_ITEM) || (hint & RESULT_PANE_CHANGE_ITEM))
  958. {
  959. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(data);
  960. Assert(pNode != NULL);
  961. //
  962. // consider only if the parent is selected, otherwise will enumerate later when selected
  963. //
  964. SPITFSNode spParentNode;
  965. pNode->GetParent(&spParentNode);
  966. if (spSelectedNode == spParentNode)
  967. {
  968. if (hint & RESULT_PANE_CHANGE_ITEM)
  969. {
  970. ChangeResultPaneItem(pComponent, pNode, hint);
  971. }
  972. else if ( hint == RESULT_PANE_ADD_ITEM)
  973. {
  974. AddResultPaneItem(pComponent, pNode);
  975. }
  976. else if ( hint == RESULT_PANE_DELETE_ITEM)
  977. {
  978. DeleteResultPaneItem(pComponent, pNode);
  979. }
  980. }
  981. }
  982. else
  983. if ( hint == RESULT_PANE_SET_VIRTUAL_LB_SIZE )
  984. {
  985. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  986. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  987. if (pNode == spSelectedNode)
  988. {
  989. SetVirtualLbSize(pComponent, data);
  990. }
  991. }
  992. else
  993. if ( hint == RESULT_PANE_CLEAR_VIRTUAL_LB )
  994. {
  995. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  996. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  997. if (pNode == spSelectedNode)
  998. {
  999. ClearVirtualLb(pComponent, data);
  1000. }
  1001. }
  1002. else
  1003. if ( hint == RESULT_PANE_EXPAND )
  1004. {
  1005. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  1006. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  1007. SPIConsole spConsole;
  1008. pComponent->GetConsole(&spConsole);
  1009. spConsole->Expand(pNode->GetData(TFS_DATA_SCOPEID), (BOOL)data);
  1010. }
  1011. else
  1012. if (hint == RESULT_PANE_SHOW_MESSAGE)
  1013. {
  1014. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  1015. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  1016. BOOL fOldMessageView = (BOOL) data;
  1017. //
  1018. // do it only if selected
  1019. //
  1020. if (spSelectedNode == pNode)
  1021. {
  1022. if (!fOldMessageView)
  1023. {
  1024. SPIConsole spConsole;
  1025. pComponent->GetConsole(&spConsole);
  1026. spConsole->SelectScopeItem(pNode->GetData(TFS_DATA_SCOPEID));
  1027. }
  1028. else
  1029. {
  1030. ShowResultMessage(pComponent, spInternal->m_cookie, NULL, NULL);
  1031. }
  1032. }
  1033. }
  1034. else
  1035. if (hint == RESULT_PANE_CLEAR_MESSAGE)
  1036. {
  1037. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  1038. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  1039. BOOL fOldMessageView = (BOOL) data;
  1040. //
  1041. // do it only if selected
  1042. //
  1043. if (spSelectedNode == pNode)
  1044. {
  1045. if (fOldMessageView)
  1046. {
  1047. SPIConsole spConsole;
  1048. pComponent->GetConsole(&spConsole);
  1049. spConsole->SelectScopeItem(pNode->GetData(TFS_DATA_SCOPEID));
  1050. }
  1051. }
  1052. }
  1053. // else if
  1054. return hrOK;
  1055. }
  1056. /*!--------------------------------------------------------------------------
  1057. CBaseResultHandler::ChangeResultPaneItem
  1058. Implementation of ChangeResultPaneItem
  1059. Author: EricDav
  1060. ---------------------------------------------------------------------------*/
  1061. HRESULT
  1062. CBaseResultHandler::ChangeResultPaneItem
  1063. (
  1064. ITFSComponent * pComponent,
  1065. ITFSNode * pNode,
  1066. LPARAM changeMask
  1067. )
  1068. {
  1069. Assert(changeMask & RESULT_PANE_CHANGE_ITEM);
  1070. Assert(pNode != NULL);
  1071. HRESULTITEM itemID;
  1072. HRESULT hr = hrOK;
  1073. SPIResultData pResultData;
  1074. CORg ( pComponent->GetResultData(&pResultData) );
  1075. CORg ( pResultData->FindItemByLParam(static_cast<LPARAM>(pNode->GetData(TFS_DATA_COOKIE)), &itemID) );
  1076. RESULTDATAITEM resultItem;
  1077. ZeroMemory(&resultItem, sizeof(RESULTDATAITEM));
  1078. resultItem.itemID = itemID;
  1079. if (changeMask & RESULT_PANE_CHANGE_ITEM_DATA)
  1080. {
  1081. resultItem.mask |= RDI_STR;
  1082. resultItem.str = MMC_CALLBACK;
  1083. }
  1084. if (changeMask & RESULT_PANE_CHANGE_ITEM_ICON)
  1085. {
  1086. resultItem.mask |= RDI_IMAGE;
  1087. resultItem.nImage = (int)pNode->GetData(TFS_DATA_IMAGEINDEX);
  1088. }
  1089. CORg ( pResultData->SetItem(&resultItem) );
  1090. CORg ( pResultData->UpdateItem(itemID) );
  1091. Error:
  1092. return hr;
  1093. }
  1094. /*!--------------------------------------------------------------------------
  1095. CBaseResultHandler::AddResultPaneItem
  1096. Implementation of AddResultPaneItem
  1097. Author: EricDav
  1098. ---------------------------------------------------------------------------*/
  1099. HRESULT
  1100. CBaseResultHandler::AddResultPaneItem
  1101. (
  1102. ITFSComponent * pComponent,
  1103. ITFSNode * pNode
  1104. )
  1105. {
  1106. Assert(pNode != NULL);
  1107. RESULTDATAITEM dataitemResult;
  1108. HRESULT hr = hrOK;
  1109. SPIResultData pResultData;
  1110. CORg ( pComponent->GetResultData(&pResultData) );
  1111. ZeroMemory(&dataitemResult, sizeof(dataitemResult));
  1112. dataitemResult.mask = RDI_STR | RDI_IMAGE | RDI_PARAM;
  1113. dataitemResult.str = MMC_CALLBACK;
  1114. dataitemResult.mask |= SDI_IMAGE;
  1115. dataitemResult.nImage = (int)pNode->GetData(TFS_DATA_IMAGEINDEX);
  1116. dataitemResult.lParam = static_cast<LPARAM>(pNode->GetData(TFS_DATA_COOKIE));
  1117. CORg ( pResultData->InsertItem(&dataitemResult) );
  1118. Error:
  1119. return hr;
  1120. }
  1121. /*!--------------------------------------------------------------------------
  1122. CBaseResultHandler::DeleteResultPaneItem
  1123. Implementation of DeleteResultPaneItem
  1124. Author: EricDav
  1125. ---------------------------------------------------------------------------*/
  1126. HRESULT
  1127. CBaseResultHandler::DeleteResultPaneItem
  1128. (
  1129. ITFSComponent * pComponent,
  1130. ITFSNode * pNode
  1131. )
  1132. {
  1133. Assert(pNode != NULL);
  1134. HRESULT hr = hrOK;
  1135. HRESULTITEM itemID;
  1136. SPIResultData pResultData;
  1137. CORg ( pComponent->GetResultData(&pResultData) );
  1138. CORg ( pResultData->FindItemByLParam(static_cast<LPARAM>(pNode->GetData(TFS_DATA_COOKIE)), &itemID) );
  1139. CORg ( pResultData->DeleteItem(itemID, 0 /* all cols */) );
  1140. Error:
  1141. return hr;
  1142. }
  1143. /*!--------------------------------------------------------------------------
  1144. CBaseResultHandler::SetVirtualLbSize
  1145. Sets the virtual listbox count. Over-ride this if you need to
  1146. specify and options.
  1147. Author: EricDav
  1148. ---------------------------------------------------------------------------*/
  1149. HRESULT
  1150. CBaseResultHandler::SetVirtualLbSize
  1151. (
  1152. ITFSComponent * pComponent,
  1153. LONG_PTR data
  1154. )
  1155. {
  1156. HRESULT hr = hrOK;
  1157. SPIResultData spResultData;
  1158. CORg (pComponent->GetResultData(&spResultData));
  1159. CORg (spResultData->SetItemCount((int) data, MMCLV_UPDATE_NOINVALIDATEALL));
  1160. Error:
  1161. return hr;
  1162. }
  1163. /*!--------------------------------------------------------------------------
  1164. CBaseResultHandler::ClearVirtualLb
  1165. Sets the virtual listbox count. Over-ride this if you need to
  1166. specify and options.
  1167. Author: EricDav
  1168. ---------------------------------------------------------------------------*/
  1169. HRESULT
  1170. CBaseResultHandler::ClearVirtualLb
  1171. (
  1172. ITFSComponent * pComponent,
  1173. LONG_PTR data
  1174. )
  1175. {
  1176. HRESULT hr = hrOK;
  1177. SPIResultData spResultData;
  1178. CORg (pComponent->GetResultData(&spResultData));
  1179. CORg (spResultData->SetItemCount((int) data, 0));
  1180. Error:
  1181. return hr;
  1182. }
  1183. /*!--------------------------------------------------------------------------
  1184. CBaseResultHandler::OnResultActivate
  1185. -
  1186. Author: KennT
  1187. ---------------------------------------------------------------------------*/
  1188. HRESULT CBaseResultHandler::OnResultActivate(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM param)
  1189. {
  1190. Trace0("IComponent::Notify(MMCN_ACTIVATE) received\n");
  1191. return S_FALSE;
  1192. }
  1193. /*!--------------------------------------------------------------------------
  1194. CBaseResultHandler::OnResultItemClkOrDblClk
  1195. -
  1196. Author: KennT
  1197. ---------------------------------------------------------------------------*/
  1198. HRESULT CBaseResultHandler::OnResultItemClkOrDblClk(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM param, BOOL bDoubleClick)
  1199. {
  1200. if (!bDoubleClick)
  1201. Trace0("IComponent::Notify(MMCN_CLK) received\n");
  1202. else
  1203. Trace0("IComponent::Notify(MMCN_DBLCLK) received\n");
  1204. // return false so that MMC does the default behavior (open the node);
  1205. return S_FALSE;
  1206. }
  1207. /*!--------------------------------------------------------------------------
  1208. CBaseResultHandler::OnResultShow
  1209. -
  1210. Author: KennT
  1211. ---------------------------------------------------------------------------*/
  1212. HRESULT CBaseResultHandler::OnResultShow(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1213. {
  1214. // Note - arg is TRUE when it is time to enumerate
  1215. if (arg == TRUE)
  1216. {
  1217. // show the result view message if there is one
  1218. ShowResultMessage(pComponent, cookie, arg, lParam);
  1219. // Show the headers for this nodetype
  1220. LoadColumns(pComponent, cookie, arg, lParam);
  1221. EnumerateResultPane(pComponent, cookie, arg, lParam);
  1222. SortColumns(pComponent);
  1223. SPITFSNode spNode;
  1224. m_spResultNodeMgr->FindNode(cookie, &spNode);
  1225. pComponent->SetSelectedNode(spNode);
  1226. }
  1227. else
  1228. {
  1229. SaveColumns(pComponent, cookie, arg, lParam);
  1230. pComponent->SetSelectedNode(NULL);
  1231. // Free data associated with the result pane items, because
  1232. // your node is no longer being displayed.
  1233. // Note: The console will remove the items from the result pane
  1234. }
  1235. return hrOK;
  1236. }
  1237. /*!--------------------------------------------------------------------------
  1238. CBaseResultHandler::OnResultColumnClick
  1239. -
  1240. Author: KennT
  1241. ---------------------------------------------------------------------------*/
  1242. HRESULT CBaseResultHandler::OnResultColumnClick(ITFSComponent *pComponent, LPARAM iColumn, BOOL fAscending)
  1243. {
  1244. return S_FALSE;
  1245. }
  1246. /*!--------------------------------------------------------------------------
  1247. CBaseResultHandler::OnResultColumnsChanged
  1248. -
  1249. Author: KennT
  1250. ---------------------------------------------------------------------------*/
  1251. HRESULT CBaseResultHandler::OnResultColumnsChanged(ITFSComponent *, LPDATAOBJECT, MMC_VISIBLE_COLUMNS *)
  1252. {
  1253. return S_FALSE;
  1254. }
  1255. /*!--------------------------------------------------------------------------
  1256. CBaseResultHandler::ShowResultMessage
  1257. -
  1258. Author: EricDav
  1259. ---------------------------------------------------------------------------*/
  1260. HRESULT CBaseResultHandler::ShowResultMessage(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1261. {
  1262. HRESULT hr = hrOK;
  1263. SPIMessageView spMessageView;
  1264. SPIUnknown spUnknown;
  1265. SPIConsole spConsole;
  1266. LPOLESTR pText = NULL;
  1267. // put up our message text
  1268. if (m_fMessageView)
  1269. {
  1270. if (pComponent)
  1271. {
  1272. CORg ( pComponent->GetConsole(&spConsole) );
  1273. CORg ( spConsole->QueryResultView(&spUnknown) );
  1274. CORg ( spMessageView.HrQuery(spUnknown) );
  1275. }
  1276. // set the title text
  1277. pText = (LPOLESTR)CoTaskMemAlloc (sizeof(OLECHAR) * (m_strMessageTitle.GetLength() + 1));
  1278. if (pText)
  1279. {
  1280. lstrcpy (pText, m_strMessageTitle);
  1281. CORg(spMessageView->SetTitleText(pText));
  1282. // bugid:148215 vivekk
  1283. CoTaskMemFree(pText);
  1284. }
  1285. // set the body text
  1286. pText = (LPOLESTR)CoTaskMemAlloc (sizeof(OLECHAR) * (m_strMessageBody.GetLength() + 1));
  1287. if (pText)
  1288. {
  1289. lstrcpy (pText, m_strMessageBody);
  1290. CORg(spMessageView->SetBodyText(pText));
  1291. // bugid:148215 vivekk
  1292. CoTaskMemFree(pText);
  1293. }
  1294. // set the icon
  1295. CORg(spMessageView->SetIcon(m_lMessageIcon));
  1296. COM_PROTECT_ERROR_LABEL;
  1297. }
  1298. return hr;
  1299. }
  1300. /*!--------------------------------------------------------------------------
  1301. CBaseResultHandler::ShowMessage
  1302. -
  1303. Author: EricDav
  1304. ---------------------------------------------------------------------------*/
  1305. HRESULT CBaseResultHandler::ShowMessage(ITFSNode * pNode, LPCTSTR pszTitle, LPCTSTR pszBody, IconIdentifier lIcon)
  1306. {
  1307. HRESULT hr = hrOK;
  1308. SPIComponentData spCompData;
  1309. SPIConsole spConsole;
  1310. SPIDataObject spDataObject;
  1311. IDataObject * pDataObject;
  1312. BOOL fOldMessageView;
  1313. m_strMessageTitle = pszTitle;
  1314. m_strMessageBody = pszBody;
  1315. m_lMessageIcon = lIcon;
  1316. fOldMessageView = m_fMessageView;
  1317. m_fMessageView = TRUE;
  1318. // tell the views to update themselves here
  1319. m_spResultNodeMgr->GetComponentData(&spCompData);
  1320. CORg ( spCompData->QueryDataObject((MMC_COOKIE) pNode, CCT_SCOPE, &pDataObject) );
  1321. spDataObject = pDataObject;
  1322. CORg ( m_spResultNodeMgr->GetConsole(&spConsole) );
  1323. CORg ( spConsole->UpdateAllViews(pDataObject, (LPARAM) fOldMessageView, RESULT_PANE_SHOW_MESSAGE) );
  1324. COM_PROTECT_ERROR_LABEL;
  1325. return hr;
  1326. }
  1327. /*!--------------------------------------------------------------------------
  1328. CBaseResultHandler::ClearMessage
  1329. -
  1330. Author: EricDav
  1331. ---------------------------------------------------------------------------*/
  1332. HRESULT CBaseResultHandler::ClearMessage(ITFSNode * pNode)
  1333. {
  1334. HRESULT hr = hrOK;
  1335. SPIComponentData spCompData;
  1336. SPIConsole spConsole;
  1337. SPIDataObject spDataObject;
  1338. IDataObject * pDataObject;
  1339. BOOL fOldMessageView;
  1340. fOldMessageView = m_fMessageView;
  1341. m_fMessageView = FALSE;
  1342. // tell the views to update themselves here
  1343. m_spResultNodeMgr->GetComponentData(&spCompData);
  1344. CORg ( spCompData->QueryDataObject((MMC_COOKIE) pNode, CCT_SCOPE, &pDataObject) );
  1345. spDataObject = pDataObject;
  1346. CORg ( m_spResultNodeMgr->GetConsole(&spConsole) );
  1347. CORg ( spConsole->UpdateAllViews(pDataObject, (LPARAM) fOldMessageView, RESULT_PANE_CLEAR_MESSAGE) );
  1348. COM_PROTECT_ERROR_LABEL;
  1349. return hr;
  1350. }
  1351. /*!--------------------------------------------------------------------------
  1352. CBaseResultHandler::LoadColumns
  1353. -
  1354. Author: EricDav
  1355. ---------------------------------------------------------------------------*/
  1356. HRESULT CBaseResultHandler::LoadColumns(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1357. {
  1358. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1359. SPIHeaderCtrl spHeaderCtrl;
  1360. pComponent->GetHeaderCtrl(&spHeaderCtrl);
  1361. CString str;
  1362. int i = 0;
  1363. if (!m_pColumnStringIDs)
  1364. return hrOK;
  1365. if (!m_fMessageView)
  1366. {
  1367. while (TRUE)
  1368. {
  1369. int nColumnWidth = AUTO_WIDTH;
  1370. if ( 0 == m_pColumnStringIDs[i] )
  1371. break;
  1372. str.LoadString(m_pColumnStringIDs[i]);
  1373. if (m_pColumnWidths)
  1374. nColumnWidth = m_pColumnWidths[i];
  1375. spHeaderCtrl->InsertColumn(i,
  1376. const_cast<LPTSTR>((LPCWSTR)str),
  1377. m_nColumnFormat,
  1378. nColumnWidth);
  1379. i++;
  1380. }
  1381. }
  1382. return hrOK;
  1383. }
  1384. /*!--------------------------------------------------------------------------
  1385. CBaseResultHandler::SaveColumns
  1386. -
  1387. Author: KennT
  1388. ---------------------------------------------------------------------------*/
  1389. HRESULT CBaseResultHandler::SaveColumns(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1390. {
  1391. return S_FALSE;
  1392. }
  1393. /*!--------------------------------------------------------------------------
  1394. CBaseResultHandler::SortColumns
  1395. -
  1396. Author: KennT
  1397. ---------------------------------------------------------------------------*/
  1398. HRESULT CBaseResultHandler::SortColumns(ITFSComponent *pComponent)
  1399. {
  1400. return S_FALSE;
  1401. }
  1402. /*!--------------------------------------------------------------------------
  1403. CBaseResultHandler::EnumerateResultPane
  1404. -
  1405. Author: EricDav
  1406. ---------------------------------------------------------------------------*/
  1407. HRESULT CBaseResultHandler::EnumerateResultPane(ITFSComponent * pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1408. {
  1409. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1410. SPITFSNode spContainer;
  1411. m_spResultNodeMgr->FindNode(cookie, &spContainer);
  1412. //
  1413. // Walk the list of children to see if there's anything
  1414. // to put in the result pane
  1415. //
  1416. SPITFSNodeEnum spNodeEnum;
  1417. ITFSNode * pCurrentNode;
  1418. ULONG nNumReturned = 0;
  1419. spContainer->GetEnum(&spNodeEnum);
  1420. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  1421. while (nNumReturned)
  1422. {
  1423. //
  1424. // All containers go into the scope pane and automatically get
  1425. // put into the result pane for us by the MMC
  1426. //
  1427. if (!pCurrentNode->IsContainer() && pCurrentNode->IsVisible())
  1428. {
  1429. AddResultPaneItem(pComponent, pCurrentNode);
  1430. }
  1431. pCurrentNode->Release();
  1432. spNodeEnum->Next(1, &pCurrentNode, &nNumReturned);
  1433. }
  1434. return hrOK;
  1435. }
  1436. /*!--------------------------------------------------------------------------
  1437. CBaseResultHandler::OnResultSelect
  1438. -
  1439. Author: EricDav
  1440. ---------------------------------------------------------------------------*/
  1441. HRESULT CBaseResultHandler::OnResultSelect(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1442. {
  1443. HRESULT hr = hrOK;
  1444. SPIConsoleVerb spConsoleVerb;
  1445. CORg (pComponent->GetConsoleVerb(&spConsoleVerb));
  1446. // Default is to turn everything off
  1447. spConsoleVerb->SetVerbState(MMC_VERB_OPEN, HIDDEN, TRUE);
  1448. spConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, TRUE);
  1449. spConsoleVerb->SetVerbState(MMC_VERB_PASTE, HIDDEN, TRUE);
  1450. spConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, TRUE);
  1451. spConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  1452. spConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, TRUE);
  1453. spConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, TRUE);
  1454. spConsoleVerb->SetVerbState(MMC_VERB_PRINT, HIDDEN, TRUE);
  1455. Error:
  1456. return hr;
  1457. }
  1458. /*!--------------------------------------------------------------------------
  1459. CBaseResultHandler::OnResultInitOcx
  1460. -
  1461. Author: EricDav
  1462. ---------------------------------------------------------------------------*/
  1463. HRESULT CBaseResultHandler::OnResultInitOcx(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1464. {
  1465. // arg - not used
  1466. // param - contains IUnknown to the OCX
  1467. return S_FALSE;
  1468. }
  1469. /*!--------------------------------------------------------------------------
  1470. CBaseResultHandler::FIsTaskpadPreferred
  1471. -
  1472. Author: EricDav
  1473. ---------------------------------------------------------------------------*/
  1474. HRESULT CBaseResultHandler::FIsTaskpadPreferred(ITFSComponent *pComponent)
  1475. {
  1476. HRESULT hr = hrOK;
  1477. SPIConsole spConsole;
  1478. pComponent->GetConsole(&spConsole);
  1479. hr = spConsole->IsTaskpadViewPreferred();
  1480. //Error:
  1481. return hr;
  1482. }
  1483. /*!--------------------------------------------------------------------------
  1484. CBaseResultHandler::DoTaskpadResultSelect
  1485. Handlers with taskpads should override the OnResultSelect and call
  1486. this to handle setting of the selected node.
  1487. Author: EricDav
  1488. ---------------------------------------------------------------------------*/
  1489. HRESULT CBaseResultHandler::DoTaskpadResultSelect(ITFSComponent *pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam, BOOL bTaskPadView)
  1490. {
  1491. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1492. SPITFSNode spNode, spSelectedNode;
  1493. HRESULT hr = hrOK;
  1494. // if this node is being selected then set the selected node.
  1495. // this node with a taskpad gets the MMCN_SHOW when the node is
  1496. // de-selected, so that will set the selected node to NULL.
  1497. if ( (HIWORD(arg) == TRUE) &&
  1498. bTaskPadView )
  1499. {
  1500. m_spResultNodeMgr->FindNode(cookie, &spNode);
  1501. pComponent->GetSelectedNode(&spSelectedNode);
  1502. // in the normal case MMC will call whichever node is selected to
  1503. // notify that is being de-selected. In this case our handler will
  1504. // set the selected node to NULL. If the selected node is not null then
  1505. // we are just being notified of something like a selection for a context
  1506. // menu...
  1507. if (!spSelectedNode)
  1508. pComponent->SetSelectedNode(spNode);
  1509. }
  1510. // call the base class to handle anything else
  1511. return hr;
  1512. }
  1513. /*!--------------------------------------------------------------------------
  1514. CBaseResultHandler::OnGetResultViewType
  1515. MMC calls this to get the result view information
  1516. Author: EricDav
  1517. ---------------------------------------------------------------------------*/
  1518. HRESULT CBaseResultHandler::OnGetResultViewType
  1519. (
  1520. ITFSComponent * pComponent,
  1521. MMC_COOKIE cookie,
  1522. LPOLESTR * ppViewType,
  1523. long * pViewOptions
  1524. )
  1525. {
  1526. HRESULT hr = S_FALSE;
  1527. //
  1528. // use the MMC default result view if no message is specified.
  1529. // Multiple selection, or virtual listbox, override this function.
  1530. // See MMC sample code for example. The Message view uses an OCX...
  1531. //
  1532. if (m_fMessageView)
  1533. {
  1534. // create the message view thingie
  1535. *pViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  1536. LPOLESTR psz = NULL;
  1537. StringFromCLSID(CLSID_MessageView, &psz);
  1538. USES_CONVERSION;
  1539. if (psz != NULL)
  1540. {
  1541. *ppViewType = psz;
  1542. hr = S_OK;
  1543. }
  1544. }
  1545. return hr;
  1546. }
  1547. /*!--------------------------------------------------------------------------
  1548. CBaseResultHandler::GetVirtualString
  1549. called when the virtual listbox needs information on an index
  1550. Author: EricDav
  1551. ---------------------------------------------------------------------------*/
  1552. LPCWSTR CBaseResultHandler::GetVirtualString
  1553. (
  1554. int nIndex,
  1555. int nCol
  1556. )
  1557. {
  1558. return NULL;
  1559. }
  1560. /*!--------------------------------------------------------------------------
  1561. CBaseResultHandler::GetVirtualImage
  1562. called when the virtual listbox needs an image index for an item
  1563. Author: EricDav
  1564. ---------------------------------------------------------------------------*/
  1565. int CBaseResultHandler::GetVirtualImage
  1566. (
  1567. int nIndex
  1568. )
  1569. {
  1570. return 0;
  1571. }
  1572. HRESULT CBaseResultHandler::OnResultMinimize(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1573. {
  1574. Trace0("IComponent::Notify(MMCN_MINIMIZE) received\n");
  1575. return S_FALSE;
  1576. }
  1577. HRESULT CBaseResultHandler::OnResultDelete(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1578. {
  1579. Trace0("IComponent::Notify(MMCN_DELETE) received\n");
  1580. return S_FALSE;
  1581. }
  1582. HRESULT CBaseResultHandler::OnResultRename(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1583. {
  1584. Trace0("IComponent::Notify(MMCN_RENAME) received\n");
  1585. return S_FALSE;
  1586. }
  1587. HRESULT CBaseResultHandler::OnResultRefresh(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1588. {
  1589. Trace0("IComponent::Notify(MMCN_REFRESH) received\n");
  1590. return S_FALSE;
  1591. }
  1592. HRESULT CBaseResultHandler::OnResultContextHelp(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1593. {
  1594. Trace0("IComponent::Notify(MMCN_CONTEXTHELP) received\n");
  1595. return S_FALSE;
  1596. }
  1597. HRESULT CBaseResultHandler::OnResultQueryPaste(ITFSComponent * pComponent, LPDATAOBJECT pDataObject, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1598. {
  1599. Trace0("IComponent::Notify(MMCN_QUERY_PASTE) received\n");
  1600. return S_FALSE;
  1601. }
  1602. HRESULT CBaseResultHandler::OnResultVerbCopy(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1603. {
  1604. Trace0("IComponent::Notify(MMCN_VERB_COPY) received\n");
  1605. return S_FALSE;
  1606. }
  1607. HRESULT CBaseResultHandler::OnResultVerbPaste(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1608. {
  1609. Trace0("IComponent::Notify(MMCN_VERB_PASTE) received\n");
  1610. return S_FALSE;
  1611. }
  1612. HRESULT CBaseResultHandler::OnResultVerbDelete(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1613. {
  1614. Trace0("IComponent::Notify(MMCN_VERB_DELETE) received\n");
  1615. return S_FALSE;
  1616. }
  1617. HRESULT CBaseResultHandler::OnResultVerbProperties(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1618. {
  1619. Trace0("IComponent::Notify(MMCN_VERB_PROPERTIES) received\n");
  1620. return S_FALSE;
  1621. }
  1622. HRESULT CBaseResultHandler::OnResultVerbRename(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1623. {
  1624. Trace0("IComponent::Notify(MMCN_VERB_RENAME) received\n");
  1625. return S_FALSE;
  1626. }
  1627. HRESULT CBaseResultHandler::OnResultVerbRefresh(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1628. {
  1629. Trace0("IComponent::Notify(MMCN_VERB_REFRESH) received\n");
  1630. return S_FALSE;
  1631. }
  1632. HRESULT CBaseResultHandler::OnResultVerbPrint(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1633. {
  1634. Trace0("IComponent::Notify(MMCN_VERB_PRINT) received\n");
  1635. return S_FALSE;
  1636. }
  1637. HRESULT CBaseResultHandler::OnResultRestoreView(ITFSComponent *pComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  1638. {
  1639. Trace0("IComponent::Notify(MMCN_RESTORE_VIEW) received\n");
  1640. return S_FALSE;
  1641. }