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.

1997 lines
43 KiB

  1. // ResultsPane.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "SnapIn.h"
  5. #include "ScopePane.h"
  6. #include "ResultsPane.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CResultsPane
  14. IMPLEMENT_DYNCREATE(CResultsPane, CCmdTarget)
  15. /////////////////////////////////////////////////////////////////////////////
  16. // Construction/Destruction
  17. CResultsPane::CResultsPane()
  18. {
  19. EnableAutomation();
  20. m_pIResultData = NULL;
  21. m_pIHeaderCtrl = NULL;
  22. m_pIControlbar = NULL;
  23. m_pIToolbar = NULL;
  24. m_pIConsoleVerb = NULL;
  25. m_pOwnerScopePane = NULL;
  26. }
  27. CResultsPane::~CResultsPane()
  28. {
  29. }
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Creation/Destruction overrideable members
  32. bool CResultsPane::OnCreate(LPCONSOLE lpConsole)
  33. {
  34. TRACEX(_T("CResultsPane::OnCreate\n"));
  35. TRACEARGn(lpConsole);
  36. if( ! CHECKPTR(lpConsole,sizeof(IConsole)) )
  37. {
  38. TRACE(_T("lpConsole is an invalid pointer.\n"));
  39. return false;
  40. }
  41. HRESULT hr = lpConsole->QueryInterface(IID_IConsole2,(LPVOID*)&m_pIConsole);
  42. if( ! CHECKHRESULT(hr) )
  43. {
  44. TRACE(_T("FAILED : lpConsole->QueryInterface for IID_IConsole2 failed.\n"));
  45. return false;
  46. }
  47. lpConsole->Release();
  48. hr = m_pIConsole->QueryInterface(IID_IResultData, (LPVOID*)&m_pIResultData);
  49. if( ! CHECKHRESULT(hr) )
  50. {
  51. TRACE(_T("FAILED : m_pIConsole->QueryInterface for IID_IResultData failed.\n"));
  52. return false;
  53. }
  54. hr = m_pIConsole->QueryInterface(IID_IHeaderCtrl2, (LPVOID*)&m_pIHeaderCtrl);
  55. if( ! CHECKHRESULT(hr) )
  56. {
  57. TRACE(_T("FAILED : m_pIConsole->QueryInterface for IID_IHeaderCtrl2 failed.\n"));
  58. return false;
  59. }
  60. hr = m_pIConsole->SetHeader( m_pIHeaderCtrl );
  61. if( ! CHECKHRESULT(hr) )
  62. {
  63. TRACE(_T("FAILED : m_pIConsole->SetHeader failed.\n"));
  64. return false;
  65. }
  66. hr = m_pIConsole->QueryConsoleVerb( &m_pIConsoleVerb );
  67. if( ! CHECKHRESULT(hr) )
  68. {
  69. TRACE(_T("FAILED : m_pIConsole->QueryConsoleVerb failed.\n"));
  70. return false;
  71. }
  72. return true;
  73. }
  74. bool CResultsPane::OnCreateOcx(LPUNKNOWN pIUnknown)
  75. {
  76. TRACEX(_T("CResultsPane::OnCreateOcx\n"));
  77. TRACEARGn(pIUnknown);
  78. if( ! CHECKPTR(pIUnknown,sizeof(IUnknown)) )
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. bool CResultsPane::OnDestroy()
  85. {
  86. TRACEX(_T("CResultsPane::OnDestroy\n"));
  87. CScopePane* pPane = GetOwnerScopePane();
  88. if( CHECKOBJPTR(pPane,RUNTIME_CLASS(CScopePane),sizeof(CScopePane)) )
  89. {
  90. // for some goofy reason, you have to
  91. // explicitly set the header control
  92. // to NULL so MMC releases it.
  93. LPCONSOLE2 lpConsole = pPane->GetConsolePtr();
  94. lpConsole->SetHeader(NULL);
  95. lpConsole->Release();
  96. lpConsole = NULL;
  97. }
  98. if( m_pIResultData )
  99. {
  100. m_pIResultData->Release();
  101. m_pIResultData = NULL;
  102. }
  103. if( m_pIHeaderCtrl )
  104. {
  105. m_pIHeaderCtrl->Release();
  106. m_pIHeaderCtrl = NULL;
  107. }
  108. if( m_pIControlbar )
  109. {
  110. m_pIControlbar->Release();
  111. m_pIControlbar = NULL;
  112. }
  113. if( m_pIToolbar )
  114. {
  115. m_pIToolbar->Release();
  116. m_pIToolbar = NULL;
  117. }
  118. if( m_pIConsoleVerb )
  119. {
  120. m_pIConsoleVerb->Release();
  121. m_pIConsoleVerb = NULL;
  122. }
  123. return true;
  124. }
  125. /////////////////////////////////////////////////////////////////////////////
  126. // Owner Scope Pane Members
  127. CScopePane* CResultsPane::GetOwnerScopePane() const
  128. {
  129. TRACEX(_T("CResultsPane::GetOwnerScopePane\n"));
  130. if( ! CHECKOBJPTR(m_pOwnerScopePane,RUNTIME_CLASS(CScopePane),sizeof(CScopePane)) )
  131. {
  132. TRACE(_T("FAILED : m_pOwnerScopePane pointer is invalid.\n"));
  133. return NULL;
  134. }
  135. return m_pOwnerScopePane;
  136. }
  137. void CResultsPane::SetOwnerScopePane(CScopePane* pOwnerPane)
  138. {
  139. TRACEX(_T("CResultsPane::SetOwnerScopePane\n"));
  140. TRACEARGn(pOwnerPane);
  141. if( ! CHECKOBJPTR(pOwnerPane,RUNTIME_CLASS(CScopePane),sizeof(CScopePane)) )
  142. {
  143. TRACE(_T("FAILED : Bad Scope Pane pointer passed.\n"));
  144. return;
  145. }
  146. m_pOwnerScopePane = pOwnerPane;
  147. return;
  148. }
  149. /////////////////////////////////////////////////////////////////////////////
  150. // MMC Interface Members
  151. LPCONSOLE2 CResultsPane::GetConsolePtr() const
  152. {
  153. TRACEX(_T("CResultsPane::GetConsolePtr\n"));
  154. if( ! CHECKPTR(m_pIConsole,sizeof(IConsole2)) )
  155. {
  156. TRACE(_T("FAILED : m_pIConsole is invalid.\n"));
  157. return NULL;
  158. }
  159. m_pIConsole->AddRef();
  160. return m_pIConsole;
  161. }
  162. LPRESULTDATA CResultsPane::GetResultDataPtr() const
  163. {
  164. TRACEX(_T("CResultsPane::GetResultDataPtr\n"));
  165. if( ! CHECKPTR(m_pIResultData,sizeof(IResultData)) )
  166. {
  167. TRACE(_T("FAILED : m_pIResultData is invalid.\n"));
  168. return NULL;
  169. }
  170. m_pIResultData->AddRef();
  171. return m_pIResultData;
  172. }
  173. LPHEADERCTRL2 CResultsPane::GetHeaderCtrlPtr() const
  174. {
  175. TRACEX(_T("CResultsPane::GetHeaderCtrlPtr\n"));
  176. if( ! CHECKPTR(m_pIHeaderCtrl,sizeof(IHeaderCtrl2)) )
  177. {
  178. TRACE(_T("FAILED : m_pIHeaderCtrl is invalid.\n"));
  179. return NULL;
  180. }
  181. m_pIHeaderCtrl->AddRef();
  182. return m_pIHeaderCtrl;
  183. }
  184. LPCONTROLBAR CResultsPane::GetControlbarPtr() const
  185. {
  186. TRACEX(_T("CResultsPane::GetControlbarPtr\n"));
  187. if( ! CHECKPTR(m_pIControlbar,sizeof(IControlbar)) )
  188. {
  189. TRACE(_T("FAILED : m_pIControlbar is invalid.\n"));
  190. return NULL;
  191. }
  192. m_pIControlbar->AddRef();
  193. return m_pIControlbar;
  194. }
  195. LPTOOLBAR CResultsPane::GetToolbarPtr() const
  196. {
  197. TRACEX(_T("CResultsPane::GetToolbarPtr\n"));
  198. if( ! CHECKPTR(m_pIToolbar,sizeof(IToolbar)) )
  199. {
  200. TRACE(_T("FAILED : m_pIToolbar is invalid.\n"));
  201. return NULL;
  202. }
  203. m_pIToolbar->AddRef();
  204. return m_pIToolbar;
  205. }
  206. LPCONSOLEVERB CResultsPane::GetConsoleVerbPtr() const
  207. {
  208. TRACEX(_T("CResultsPane::GetConsoleVerbPtr\n"));
  209. if( ! CHECKPTR(m_pIConsoleVerb,sizeof(IConsoleVerb)) )
  210. {
  211. TRACE(_T("FAILED : m_pIConsoleVerb is invalid.\n"));
  212. return NULL;
  213. }
  214. m_pIConsoleVerb->AddRef();
  215. return m_pIConsoleVerb;
  216. }
  217. LPIMAGELIST CResultsPane::GetImageListPtr() const
  218. {
  219. TRACEX(_T("CResultsPane::GetImageListPtr\n"));
  220. if( ! CHECKPTR(m_pIImageList,sizeof(IImageList)) )
  221. {
  222. TRACE(_T("FAILED : m_pIImageList is invalid.\n"));
  223. return NULL;
  224. }
  225. m_pIImageList->AddRef();
  226. return m_pIImageList;
  227. }
  228. /////////////////////////////////////////////////////////////////////////////
  229. // Control bar Members
  230. /////////////////////////////////////////////////////////////////////////////
  231. HRESULT CResultsPane::OnSetControlbar(LPCONTROLBAR pIControlbar)
  232. {
  233. TRACEX(_T("CResultsPane::OnSetControlbar\n"));
  234. TRACEARGn(pIControlbar);
  235. HRESULT hr = S_OK;
  236. // default behavior simply creates an empty toolbar
  237. // override to add buttons or to disallow creation of a new toolbar
  238. if( pIControlbar )
  239. {
  240. if( ! GfxCheckPtr(pIControlbar,IControlbar) )
  241. {
  242. return E_FAIL;
  243. }
  244. // hold on to that controlbar pointer
  245. pIControlbar->AddRef();
  246. m_pIControlbar = pIControlbar;
  247. // create a new toolbar that is initially empty
  248. LPEXTENDCONTROLBAR lpExtendControlBar = (LPEXTENDCONTROLBAR)GetInterface(&IID_IExtendControlbar);
  249. hr = m_pIControlbar->Create(TOOLBAR,lpExtendControlBar,(LPUNKNOWN*)(&m_pIToolbar));
  250. }
  251. else
  252. {
  253. // free the toolbar
  254. if( m_pIToolbar )
  255. {
  256. m_pIToolbar->Release();
  257. m_pIToolbar = NULL;
  258. }
  259. // free the controlbar
  260. if( m_pIControlbar )
  261. {
  262. m_pIControlbar->Release();
  263. m_pIControlbar = NULL;
  264. }
  265. }
  266. return hr;
  267. }
  268. HRESULT CResultsPane::OnControlbarNotify(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param)
  269. {
  270. TRACEX(_T("CResultsPane::OnControlbarNotify\n"));
  271. TRACEARGn(event);
  272. TRACEARGn(arg);
  273. TRACEARGn(param);
  274. HRESULT hr = S_OK;
  275. // override this virtual function to add event handlers for toolbar buttons
  276. return hr;
  277. }
  278. /////////////////////////////////////////////////////////////////////////////
  279. // Results Item Icon Management
  280. /////////////////////////////////////////////////////////////////////////////
  281. int CResultsPane::AddIcon(UINT nIconResID)
  282. {
  283. TRACEX(_T("CResultsPane::AddIcon\n"));
  284. TRACEARGn(nIconResID);
  285. if( ! CHECKPTR(m_pIImageList,sizeof(IImageList)) )
  286. {
  287. return -1;
  288. }
  289. // load icon
  290. HICON hIcon = AfxGetApp()->LoadIcon(nIconResID);
  291. if( hIcon == NULL )
  292. {
  293. TRACE(_T("FAILED : Icon with resid=%d not found"),nIconResID);
  294. return -1;
  295. }
  296. int nIconIndex = GetIconCount();
  297. // insert icon into image list
  298. #ifndef IA64
  299. if( m_pIImageList->ImageListSetIcon((long*)hIcon, nIconIndex) != S_OK )
  300. {
  301. return -1;
  302. }
  303. #endif // IA64
  304. // add resid and index to map
  305. m_IconMap.SetAt(nIconResID,nIconIndex);
  306. // return index of newly inserted image
  307. return nIconIndex;
  308. }
  309. int CResultsPane::GetIconIndex(UINT nIconResID)
  310. {
  311. TRACEX(_T("CResultsPane::GetIconIndex\n"));
  312. TRACEARGn(nIconResID);
  313. if( ! CHECKPTR(m_pIImageList,sizeof(IImageList)) )
  314. {
  315. return -1;
  316. }
  317. // check map for an existing id
  318. int nIconIndex = -1;
  319. if( m_IconMap.Lookup(nIconResID,nIconIndex) )
  320. {
  321. // if exists, return index
  322. return nIconIndex;
  323. }
  324. // does not exist so add icon
  325. nIconIndex = AddIcon(nIconResID);
  326. // if it still does not exist, icon is not in resources
  327. if( nIconIndex != -1 )
  328. return nIconIndex;
  329. TRACE(_T("FAILED : Icon with Resource id=%d could not be loaded.\n"),nIconResID);
  330. return -1;
  331. }
  332. int CResultsPane::GetIconCount()
  333. {
  334. TRACEX(_T("CResultsPane::GetIconCount\n"));
  335. return (int)m_IconMap.GetCount();
  336. }
  337. void CResultsPane::RemoveAllIcons()
  338. {
  339. TRACEX(_T("CResultsPane::RemoveAllIcons\n"));
  340. m_IconMap.RemoveAll();
  341. }
  342. void CResultsPane::OnFinalRelease()
  343. {
  344. // When the last reference for an automation object is released
  345. // OnFinalRelease is called. The base class will automatically
  346. // deletes the object. Add additional cleanup required for your
  347. // object before calling the base class.
  348. CCmdTarget::OnFinalRelease();
  349. }
  350. BEGIN_MESSAGE_MAP(CResultsPane, CCmdTarget)
  351. //{{AFX_MSG_MAP(CResultsPane)
  352. // NOTE - the ClassWizard will add and remove mapping macros here.
  353. //}}AFX_MSG_MAP
  354. END_MESSAGE_MAP()
  355. BEGIN_DISPATCH_MAP(CResultsPane, CCmdTarget)
  356. //{{AFX_DISPATCH_MAP(CResultsPane)
  357. // NOTE - the ClassWizard will add and remove mapping macros here.
  358. //}}AFX_DISPATCH_MAP
  359. END_DISPATCH_MAP()
  360. // Note: we add support for IID_IResultsPane to support typesafe binding
  361. // from VBA. This IID must match the GUID that is attached to the
  362. // dispinterface in the .ODL file.
  363. // {7D4A685B-9056-11D2-BD45-0000F87A3912}
  364. static const IID IID_IResultsPane =
  365. { 0x7d4a685b, 0x9056, 0x11d2, { 0xbd, 0x45, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
  366. BEGIN_INTERFACE_MAP(CResultsPane, CCmdTarget)
  367. INTERFACE_PART(CResultsPane, IID_IResultsPane, Dispatch)
  368. INTERFACE_PART(CResultsPane, IID_IComponent, Component)
  369. INTERFACE_PART(CResultsPane, IID_IResultDataCompare, ResultDataCompare)
  370. INTERFACE_PART(CResultsPane, IID_IExtendContextMenu, ExtendContextMenu)
  371. INTERFACE_PART(CResultsPane, IID_IExtendPropertySheet2, ExtendPropertySheet2)
  372. INTERFACE_PART(CResultsPane, IID_IExtendControlbar, ExtendControlbar)
  373. END_INTERFACE_MAP()
  374. /////////////////////////////////////////////////////////////////////////////
  375. // CResultsPane message handlers
  376. /////////////////////////////////////////////////////////////////////////////
  377. // IComponent Interface Part
  378. ULONG FAR EXPORT CResultsPane::XComponent::AddRef()
  379. {
  380. METHOD_PROLOGUE(CResultsPane, Component)
  381. return pThis->ExternalAddRef();
  382. }
  383. ULONG FAR EXPORT CResultsPane::XComponent::Release()
  384. {
  385. METHOD_PROLOGUE(CResultsPane, Component)
  386. return pThis->ExternalRelease();
  387. }
  388. HRESULT FAR EXPORT CResultsPane::XComponent::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  389. {
  390. METHOD_PROLOGUE(CResultsPane, Component)
  391. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  392. }
  393. HRESULT FAR EXPORT CResultsPane::XComponent::Initialize(
  394. /* [in] */ LPCONSOLE lpConsole)
  395. {
  396. METHOD_PROLOGUE(CResultsPane, Component)
  397. TRACEX(_T("CResultsPane::XComponent::Initialize\n"));
  398. TRACEARGn(lpConsole);
  399. if( ! pThis->OnCreate(lpConsole) )
  400. {
  401. return E_FAIL;
  402. }
  403. return S_OK;
  404. }
  405. HRESULT FAR EXPORT CResultsPane::XComponent::Notify(
  406. /* [in] */ LPDATAOBJECT lpDataObject,
  407. /* [in] */ MMC_NOTIFY_TYPE event,
  408. /* [in] */ LPARAM arg,
  409. /* [in] */ LPARAM param)
  410. {
  411. METHOD_PROLOGUE(CResultsPane, Component)
  412. TRACEX(_T("CResultsPane::XComponent::Notify\n"));
  413. TRACEARGn(lpDataObject);
  414. TRACEARGn(event);
  415. TRACEARGn(arg);
  416. TRACEARGn(param);
  417. HRESULT hr = S_OK;
  418. switch( event )
  419. {
  420. case MMCN_ACTIVATE:
  421. {
  422. TRACE(_T("MMCN_ACTIVATE received.\n"));
  423. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  424. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  425. {
  426. return E_FAIL;
  427. }
  428. if( psdo->GetItemType() != CCT_SCOPE )
  429. {
  430. TRACE(_T("WARNING : IComponent::Notify(MMCN_ACTIVATE) called with a result item instead of a scope item.\n"));
  431. return S_FALSE;
  432. }
  433. CScopePaneItem* pItem = NULL;
  434. if( ! psdo->GetItem(pItem) )
  435. {
  436. return E_FAIL;
  437. }
  438. ASSERT(pItem);
  439. hr = pItem->OnActivate((int)arg);
  440. }
  441. break;
  442. case MMCN_ADD_IMAGES:
  443. {
  444. TRACE(_T("MMCN_ADD_IMAGES received.\n"));
  445. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  446. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  447. {
  448. return E_FAIL;
  449. }
  450. if( psdo->GetItemType() != CCT_SCOPE )
  451. {
  452. TRACE(_T("WARNING : IComponent::Notify(MMCN_ACTIVATE) called with a result item instead of a scope item.\n"));
  453. return S_FALSE;
  454. }
  455. CScopePaneItem* pItem = NULL;
  456. if( ! psdo->GetItem(pItem) )
  457. {
  458. return E_FAIL;
  459. }
  460. ASSERT(pItem);
  461. pThis->RemoveAllIcons();
  462. pThis->m_pIImageList = (LPIMAGELIST)arg;
  463. hr = pItem->OnAddImages(pThis);
  464. }
  465. break;
  466. case MMCN_BTN_CLICK:
  467. {
  468. TRACE(_T("MMCN_BTN_CLICK received.\n"));
  469. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  470. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  471. {
  472. return E_FAIL;
  473. }
  474. if( psdo->GetItemType() == CCT_SCOPE )
  475. {
  476. CScopePaneItem* pItem = NULL;
  477. if( ! psdo->GetItem(pItem) )
  478. {
  479. return E_FAIL;
  480. }
  481. ASSERT(pItem);
  482. hr = pItem->OnBtnClick((MMC_CONSOLE_VERB)param);
  483. }
  484. else if( psdo->GetItemType() == CCT_RESULT )
  485. {
  486. CResultsPaneItem* pItem = NULL;
  487. if( ! psdo->GetItem(pItem) )
  488. {
  489. return E_FAIL;
  490. }
  491. ASSERT(pItem);
  492. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  493. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  494. {
  495. return E_FAIL;
  496. }
  497. hr = pView->OnBtnClick(pItem,(MMC_CONSOLE_VERB)param);
  498. }
  499. }
  500. break;
  501. case MMCN_CONTEXTHELP: // F1, Help Menu Item or Help Button selected
  502. {
  503. TRACE(_T("MMCN_CONTEXTHELP received.\n"));
  504. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  505. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  506. {
  507. return E_FAIL;
  508. }
  509. if( psdo->GetItemType() == CCT_SCOPE )
  510. {
  511. CScopePaneItem* pItem = NULL;
  512. if( ! psdo->GetItem(pItem) )
  513. {
  514. return E_FAIL;
  515. }
  516. ASSERT(pItem);
  517. hr = pItem->OnContextHelp();
  518. }
  519. else if( psdo->GetItemType() == CCT_RESULT )
  520. {
  521. CResultsPaneItem* pItem = NULL;
  522. if( ! psdo->GetItem(pItem) )
  523. {
  524. return E_FAIL;
  525. }
  526. ASSERT(pItem);
  527. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  528. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  529. {
  530. return E_FAIL;
  531. }
  532. ASSERT(pView);
  533. hr = pView->OnContextHelp(pItem);
  534. }
  535. }
  536. break;
  537. case MMCN_CUTORMOVE:
  538. {
  539. TRACE(_T("MMCN_CUTORMOVE received.\n"));
  540. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(LPDATAOBJECT(arg));
  541. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  542. {
  543. return E_FAIL;
  544. }
  545. if( psdo->GetItemType() == CCT_SCOPE )
  546. {
  547. CScopePaneItem* pItem = NULL;
  548. if( ! psdo->GetItem(pItem) )
  549. {
  550. return E_FAIL;
  551. }
  552. ASSERT(pItem);
  553. hr = pItem->OnCutOrMove();
  554. }
  555. else if( psdo->GetItemType() == CCT_RESULT )
  556. {
  557. ASSERT(FALSE);
  558. }
  559. }
  560. break;
  561. case MMCN_DBLCLICK:
  562. {
  563. TRACE(_T("MMCN_DBLCLICK received.\n"));
  564. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  565. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  566. {
  567. return E_FAIL;
  568. }
  569. if( psdo->GetItemType() != CCT_RESULT )
  570. {
  571. return S_FALSE;
  572. }
  573. CResultsPaneItem* pItem = NULL;
  574. if( ! psdo->GetItem(pItem) )
  575. {
  576. return E_FAIL;
  577. }
  578. ASSERT(pItem);
  579. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  580. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  581. {
  582. return E_FAIL;
  583. }
  584. hr = pView->OnDblClick(pItem);
  585. }
  586. break;
  587. case MMCN_DELETE:
  588. {
  589. TRACE(_T("MMCN_DELETE received.\n"));
  590. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  591. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  592. {
  593. return E_FAIL;
  594. }
  595. if( psdo->GetItemType() == CCT_SCOPE )
  596. {
  597. CScopePaneItem* pItem = NULL;
  598. if( ! psdo->GetItem(pItem) )
  599. {
  600. return E_FAIL;
  601. }
  602. ASSERT(pItem);
  603. hr = pItem->OnDelete();
  604. }
  605. else if( psdo->GetItemType() == CCT_RESULT )
  606. {
  607. CResultsPaneItem* pItem = NULL;
  608. if( ! psdo->GetItem(pItem) )
  609. {
  610. return E_FAIL;
  611. }
  612. ASSERT(pItem);
  613. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  614. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  615. {
  616. return E_FAIL;
  617. }
  618. hr = pView->OnDelete(pItem);
  619. }
  620. }
  621. break;
  622. case MMCN_EXPAND:
  623. {
  624. TRACE(_T("MMCN_EXPAND received.\n"));
  625. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  626. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  627. {
  628. return E_FAIL;
  629. }
  630. if( psdo->GetItemType() != CCT_SCOPE )
  631. {
  632. TRACE(_T("WARNING : IComponent::Notify(MMCN_EXPAND) called with a result item instead of a scope item.\n"));
  633. return S_FALSE;
  634. }
  635. CScopePaneItem* pItem = NULL;
  636. if( ! psdo->GetItem(pItem) )
  637. {
  638. return E_FAIL;
  639. }
  640. ASSERT(pItem);
  641. hr = pItem->OnExpand((int)arg);
  642. }
  643. break;
  644. case MMCN_INITOCX: // custom ocx in the results pane has been created
  645. {
  646. TRACE(_T("MMCN_INITOCX received.\n"));
  647. LPUNKNOWN pIUnknown = (LPUNKNOWN)param;
  648. if( ! CHECKPTR(pIUnknown,sizeof(IUnknown)) )
  649. {
  650. return E_FAIL;
  651. }
  652. if( ! pThis->OnCreateOcx(pIUnknown) )
  653. {
  654. TRACE(_T("FAILED : CResultsPane::OnCreateOcx failed.\n"));
  655. return E_FAIL;
  656. }
  657. hr = S_OK;
  658. }
  659. break;
  660. case MMCN_LISTPAD:
  661. {
  662. TRACE(_T("MMCN_LISTPAD received.\n"));
  663. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  664. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  665. {
  666. return E_FAIL;
  667. }
  668. if( psdo->GetItemType() != CCT_SCOPE )
  669. {
  670. TRACE(_T("WARNING : IComponent::Notify(MMCN_LISTPAD) called with a result item instead of a scope item.\n"));
  671. return S_FALSE;
  672. }
  673. CScopePaneItem* pItem = NULL;
  674. if( ! psdo->GetItem(pItem) )
  675. {
  676. return E_FAIL;
  677. }
  678. ASSERT(pItem);
  679. hr = pItem->OnListpad((int)arg);
  680. }
  681. break;
  682. case MMCN_MINIMIZED:
  683. {
  684. TRACE(_T("MMCN_MINIMIZED received.\n"));
  685. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  686. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  687. {
  688. return E_FAIL;
  689. }
  690. if( psdo->GetItemType() != CCT_SCOPE )
  691. {
  692. TRACE(_T("WARNING : IComponent::Notify(MMCN_MINIMIZED) called with a result item instead of a scope item.\n"));
  693. return S_FALSE;
  694. }
  695. CScopePaneItem* pItem = NULL;
  696. if( ! psdo->GetItem(pItem) )
  697. {
  698. return E_FAIL;
  699. }
  700. ASSERT(pItem);
  701. hr = pItem->OnMinimized((int)arg);
  702. }
  703. break;
  704. case MMCN_PASTE:
  705. {
  706. TRACE(_T("MMCN_PASTE received.\n"));
  707. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  708. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  709. {
  710. return E_FAIL;
  711. }
  712. if( psdo->GetItemType() == CCT_SCOPE )
  713. {
  714. CScopePaneItem* pItem = NULL;
  715. if( ! psdo->GetItem(pItem) )
  716. {
  717. return E_FAIL;
  718. }
  719. ASSERT(pItem);
  720. LPDATAOBJECT pSelection = LPDATAOBJECT(arg);
  721. if( ! GfxCheckPtr(pSelection,IDataObject) )
  722. {
  723. return E_FAIL;
  724. }
  725. LPDATAOBJECT* ppCopiedItems = (LPDATAOBJECT*)param;
  726. hr = pItem->OnPaste(pSelection,ppCopiedItems);
  727. }
  728. else if( psdo->GetItemType() == CCT_RESULT )
  729. {
  730. ASSERT(FALSE);
  731. }
  732. }
  733. break;
  734. case MMCN_PROPERTY_CHANGE:
  735. {
  736. TRACE(_T("MMCN_PROPERTY_CHANGE received.\n"));
  737. TRACE(_T("WARNING : Not implemented.\n"));
  738. }
  739. break;
  740. case MMCN_QUERY_PASTE:
  741. {
  742. TRACE(_T("MMCN_QUERY_PASTE received.\n"));
  743. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  744. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  745. {
  746. return E_FAIL;
  747. }
  748. if( psdo->GetItemType() == CCT_SCOPE )
  749. {
  750. CScopePaneItem* pItem = NULL;
  751. if( ! psdo->GetItem(pItem) )
  752. {
  753. return E_FAIL;
  754. }
  755. ASSERT(pItem);
  756. LPDATAOBJECT pSelection = LPDATAOBJECT(arg);
  757. if( ! GfxCheckPtr(pSelection,IDataObject) )
  758. {
  759. return E_FAIL;
  760. }
  761. hr = pItem->OnQueryPaste(pSelection);
  762. }
  763. else if( psdo->GetItemType() == CCT_RESULT )
  764. {
  765. ASSERT(FALSE);
  766. }
  767. }
  768. break;
  769. case MMCN_REFRESH:
  770. {
  771. TRACE(_T("MMCN_REFRESH received.\n"));
  772. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  773. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  774. {
  775. return E_FAIL;
  776. }
  777. if( psdo->GetItemType() == CCT_SCOPE )
  778. {
  779. CScopePaneItem* pItem = NULL;
  780. if( ! psdo->GetItem(pItem) )
  781. {
  782. return E_FAIL;
  783. }
  784. ASSERT(pItem);
  785. hr = pItem->OnRefresh();
  786. }
  787. else if( psdo->GetItemType() == CCT_RESULT )
  788. {
  789. CResultsPaneItem* pItem = NULL;
  790. if( ! psdo->GetItem(pItem) )
  791. {
  792. return E_FAIL;
  793. }
  794. ASSERT(pItem);
  795. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  796. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  797. {
  798. return E_FAIL;
  799. }
  800. ASSERT(pView);
  801. hr = pView->OnRefresh();
  802. }
  803. }
  804. break;
  805. case MMCN_REMOVE_CHILDREN:
  806. {
  807. TRACE(_T("MMCN_REMOVE_CHILDREN received.\n"));
  808. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  809. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  810. {
  811. return E_FAIL;
  812. }
  813. if( psdo->GetItemType() != CCT_SCOPE )
  814. {
  815. TRACE(_T("WARNING : IComponent::Notify(MMCN_REMOVE_CHILDREN) called with a result item instead of a scope item.\n"));
  816. return S_FALSE;
  817. }
  818. CScopePaneItem* pItem = NULL;
  819. if( ! psdo->GetItem(pItem) )
  820. {
  821. return E_FAIL;
  822. }
  823. ASSERT(pItem);
  824. hr = pItem->OnRemoveChildren();
  825. }
  826. break;
  827. case MMCN_RENAME:
  828. {
  829. TRACE(_T("MMCN_RENAME received.\n"));
  830. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  831. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  832. {
  833. return E_FAIL;
  834. }
  835. if( ! CHECKPTR((LPOLESTR)param,sizeof(LPOLESTR)) )
  836. {
  837. TRACE(_T("FAILED : Invalid string pointer passed.\n"));
  838. return E_INVALIDARG;
  839. }
  840. CString sNewName = (LPOLESTR)param;
  841. if( psdo->GetItemType() == CCT_SCOPE )
  842. {
  843. CScopePaneItem* pItem = NULL;
  844. if( ! psdo->GetItem(pItem) )
  845. {
  846. return E_FAIL;
  847. }
  848. ASSERT(pItem);
  849. hr = pItem->OnRename(sNewName);
  850. }
  851. else if( psdo->GetItemType() == CCT_RESULT )
  852. {
  853. CResultsPaneItem* pItem = NULL;
  854. if( ! psdo->GetItem(pItem) )
  855. {
  856. return E_FAIL;
  857. }
  858. ASSERT(pItem);
  859. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  860. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  861. {
  862. return E_FAIL;
  863. }
  864. hr = pView->OnRename(pItem, sNewName);
  865. }
  866. }
  867. break;
  868. case MMCN_RESTORE_VIEW:
  869. {
  870. TRACE(_T("MMCN_RESTORE_VIEW received.\n"));
  871. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  872. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  873. {
  874. return E_FAIL;
  875. }
  876. if( psdo->GetItemType() != CCT_SCOPE )
  877. {
  878. TRACE(_T("WARNING : IComponent::Notify(MMCN_RESTORE_VIEW) called with a result item instead of a scope item.\n"));
  879. return S_FALSE;
  880. }
  881. if( ! CHECKPTR((MMC_RESTORE_VIEW*)arg,sizeof(MMC_RESTORE_VIEW)) )
  882. {
  883. TRACE(_T("FAILED : Pointer to MMC_RESTORE_VIEW is invalid.\n"));
  884. return E_INVALIDARG;
  885. }
  886. if( ! CHECKPTR((BOOL*)param,sizeof(BOOL)) )
  887. {
  888. TRACE(_T("FAILED : Pointer to BOOL is invalid.\n"));
  889. return E_INVALIDARG;
  890. }
  891. CScopePaneItem* pItem = NULL;
  892. if( ! psdo->GetItem(pItem) )
  893. {
  894. return E_FAIL;
  895. }
  896. ASSERT(pItem);
  897. hr = pItem->OnRestoreView((MMC_RESTORE_VIEW*)arg,(BOOL*)param);
  898. }
  899. break;
  900. case MMCN_SELECT:
  901. {
  902. TRACE(_T("MMCN_SELECT received.\n"));
  903. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  904. if( !psdo || ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  905. {
  906. return E_FAIL;
  907. }
  908. BOOL bIsScopeItem = LOWORD(arg);
  909. BOOL bIsSelected = HIWORD(arg);
  910. if( psdo->GetItemType() == CCT_SCOPE )
  911. {
  912. if( ! bIsScopeItem )
  913. {
  914. TRACE(_T("FAILED : Data Object is of type scope item where boolean flag indicates result item type.\n"));
  915. ASSERT(FALSE);
  916. return E_FAIL;
  917. }
  918. CScopePaneItem* pItem = NULL;
  919. if( ! psdo->GetItem(pItem) )
  920. {
  921. return E_FAIL;
  922. }
  923. ASSERT(pItem);
  924. hr = pItem->OnSelect(pThis,bIsSelected);
  925. }
  926. else if( psdo->GetItemType() == CCT_RESULT )
  927. {
  928. if( ! bIsScopeItem )
  929. {
  930. TRACE(_T("FAILED : Data Object is of type result item where boolean flag indicates scope item type.\n"));
  931. ASSERT(FALSE);
  932. return E_FAIL;
  933. }
  934. CResultsPaneItem* pItem = NULL;
  935. if( ! psdo->GetItem(pItem) )
  936. {
  937. return E_FAIL;
  938. }
  939. ASSERT(pItem);
  940. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  941. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  942. {
  943. return E_FAIL;
  944. }
  945. hr = pView->OnSelect(pThis, pItem, bIsSelected);
  946. }
  947. if( pThis->m_pIControlbar )
  948. {
  949. hr = pThis->m_pIControlbar->Attach(TOOLBAR, (LPUNKNOWN)pThis->m_pIToolbar);
  950. ASSERT( SUCCEEDED(hr) );
  951. }
  952. }
  953. break;
  954. case MMCN_SHOW:
  955. {
  956. TRACE(_T("MMCN_SHOW received.\n"));
  957. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  958. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  959. {
  960. return E_FAIL;
  961. }
  962. if( psdo->GetItemType() != CCT_SCOPE )
  963. {
  964. TRACE(_T("WARNING : IComponent::Notify(MMCN_SHOW) called with a result item instead of a scope item.\n"));
  965. return S_FALSE;
  966. }
  967. BOOL bIsSelected = (BOOL)arg;
  968. CScopePaneItem* pItem = NULL;
  969. if( ! psdo->GetItem(pItem) )
  970. {
  971. return E_FAIL;
  972. }
  973. ASSERT(pItem);
  974. CResultsPaneView* pView = pItem->GetResultsPaneView();
  975. if( ! pView )
  976. {
  977. TRACE(_T("FAILED : CScopePaneItem::GetResultsPaneView failed.\n"));
  978. return E_FAIL;
  979. }
  980. if( bIsSelected )
  981. {
  982. pView->AddResultsPane(pThis);
  983. }
  984. else
  985. {
  986. pView->RemoveResultsPane(pThis);
  987. }
  988. hr = pItem->OnShow(pThis,bIsSelected);
  989. }
  990. break;
  991. case MMCN_VIEW_CHANGE:
  992. {
  993. TRACE(_T("MMCN_VIEW_CHANGE received.\n"));
  994. TRACE(_T("WARNING : Not implmented.\n"));
  995. }
  996. break;
  997. }
  998. return hr;
  999. }
  1000. HRESULT FAR EXPORT CResultsPane::XComponent::Destroy(
  1001. /* [in] */ MMC_COOKIE cookie)
  1002. {
  1003. METHOD_PROLOGUE(CResultsPane, Component)
  1004. TRACEX(_T("CResultsPane::XComponent::Destroy\n"));
  1005. TRACEARGn(cookie);
  1006. if( ! pThis->OnDestroy() )
  1007. {
  1008. return E_FAIL;
  1009. }
  1010. return S_OK;
  1011. }
  1012. HRESULT FAR EXPORT CResultsPane::XComponent::QueryDataObject(
  1013. /* [in] */ MMC_COOKIE cookie,
  1014. /* [in] */ DATA_OBJECT_TYPES type,
  1015. /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
  1016. {
  1017. METHOD_PROLOGUE(CResultsPane, Component)
  1018. TRACEX(_T("CResultsPane::XComponent::QueryDataObject\n"));
  1019. TRACEARGn(cookie);
  1020. TRACEARGn(type);
  1021. TRACEARGn(ppDataObject);
  1022. HRESULT hr = S_OK;
  1023. CSnapinDataObject* pdoNew = NULL;
  1024. pdoNew = new CSnapinDataObject;
  1025. if( ! pdoNew )
  1026. {
  1027. hr = E_OUTOFMEMORY;
  1028. *ppDataObject = NULL;
  1029. TRACE(_T("Out of memory.\n"));
  1030. return hr;
  1031. }
  1032. *ppDataObject = (LPDATAOBJECT)pdoNew->GetInterface(&IID_IDataObject);
  1033. if( ! CHECKOBJPTR(pdoNew,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  1034. {
  1035. return E_FAIL;
  1036. }
  1037. if( cookie )
  1038. {
  1039. if( type == CCT_SCOPE )
  1040. {
  1041. CScopePaneItem* pItem = (CScopePaneItem*)cookie;
  1042. if( ! CHECKOBJPTR(pItem,RUNTIME_CLASS(CScopePaneItem),sizeof(CScopePaneItem)) )
  1043. {
  1044. return E_FAIL;
  1045. }
  1046. pdoNew->SetItem(pItem);
  1047. ASSERT(pdoNew->GetItemType() == CCT_SCOPE);
  1048. }
  1049. else if( type == CCT_RESULT )
  1050. {
  1051. CResultsPaneItem* pItem = (CResultsPaneItem*)cookie;
  1052. if( ! CHECKOBJPTR(pItem,RUNTIME_CLASS(CResultsPaneItem),sizeof(CResultsPaneItem)) )
  1053. {
  1054. return E_FAIL;
  1055. }
  1056. pdoNew->SetItem(pItem);
  1057. ASSERT(pdoNew->GetItemType() == CCT_RESULT);
  1058. }
  1059. }
  1060. else // In this case the node is our root scope item, and was placed there for us by MMC.
  1061. {
  1062. CScopePane* pPane = pThis->GetOwnerScopePane();
  1063. if( ! CHECKOBJPTR(pPane,RUNTIME_CLASS(CScopePane),sizeof(CScopePane)) )
  1064. {
  1065. return E_FAIL;
  1066. }
  1067. pdoNew->SetItem( pPane->GetRootScopeItem() );
  1068. ASSERT(pdoNew->GetItemType() == CCT_SCOPE);
  1069. }
  1070. return hr;
  1071. }
  1072. HRESULT FAR EXPORT CResultsPane::XComponent::GetResultViewType(
  1073. /* [in] */ MMC_COOKIE cookie,
  1074. /* [out] */ LPOLESTR __RPC_FAR *ppViewType,
  1075. /* [out] */ long __RPC_FAR *pViewOptions)
  1076. {
  1077. METHOD_PROLOGUE(CResultsPane, Component)
  1078. TRACEX(_T("CResultsPane::XComponent::GetResultViewType\n"));
  1079. TRACEARGn(cookie);
  1080. TRACEARGn(ppViewType);
  1081. TRACEARGn(pViewOptions);
  1082. CScopePaneItem* pItem = NULL;
  1083. if( cookie == NULL ) // this is the root item
  1084. {
  1085. CScopePane* pPane = pThis->GetOwnerScopePane();
  1086. if( ! pPane )
  1087. {
  1088. TRACE(_T("FAIELD : CResultsPane::GetOwnerScopePane returns NULL.\n"));
  1089. return E_FAIL;
  1090. }
  1091. pItem = pPane->GetRootScopeItem();
  1092. }
  1093. else
  1094. {
  1095. pItem = (CScopePaneItem*)cookie;
  1096. }
  1097. if( ! CHECKOBJPTR(pItem,RUNTIME_CLASS(CScopePaneItem),sizeof(CScopePaneItem)) )
  1098. {
  1099. TRACE(_T("FAILED : cookie passed to snapin is not a valid scope pane item type.\n"));
  1100. return E_INVALIDARG;
  1101. }
  1102. ASSERT(pItem);
  1103. CString sViewType;
  1104. long lViewOptions = 0L;
  1105. HRESULT hr = pItem->OnGetResultViewType(sViewType,lViewOptions);
  1106. *pViewOptions = lViewOptions;
  1107. if( ! sViewType.IsEmpty() )
  1108. {
  1109. *ppViewType = reinterpret_cast<LPOLESTR>(CoTaskMemAlloc((sViewType.GetLength() + 1)* sizeof(wchar_t)));
  1110. if (*ppViewType == NULL)
  1111. return E_OUTOFMEMORY;
  1112. _tcscpy(*ppViewType, (LPCTSTR)sViewType);
  1113. }
  1114. else
  1115. {
  1116. *ppViewType = NULL;
  1117. }
  1118. return hr;
  1119. }
  1120. HRESULT FAR EXPORT CResultsPane::XComponent::GetDisplayInfo(
  1121. /* [out][in] */ RESULTDATAITEM __RPC_FAR *pResultDataItem)
  1122. {
  1123. METHOD_PROLOGUE(CResultsPane, Component)
  1124. TRACEX(_T("CResultsPane::XComponent::GetDisplayInfo\n"));
  1125. TRACEARGn(pResultDataItem);
  1126. if( ! CHECKPTR(pResultDataItem,sizeof(RESULTDATAITEM)) )
  1127. {
  1128. TRACE(_T("FAILED : pResultDataItem is an invalid pointer.\n"));
  1129. return E_INVALIDARG;
  1130. }
  1131. if( pResultDataItem->bScopeItem ) // for the scope pane items
  1132. {
  1133. CScopePaneItem* pItem = (CScopePaneItem*)pResultDataItem->lParam;
  1134. if( ! CHECKOBJPTR(pItem,RUNTIME_CLASS(CScopePaneItem),sizeof(CScopePaneItem)) )
  1135. {
  1136. TRACE(_T("FAILED : Invalid lParam in RESULTDATAITEM struct.\n"));
  1137. return E_FAIL;
  1138. }
  1139. if( pResultDataItem->mask & RDI_STR )
  1140. {
  1141. pResultDataItem->str = (LPTSTR)(LPCTSTR)pItem->GetDisplayName(pResultDataItem->nCol);
  1142. }
  1143. if( pResultDataItem->mask & RDI_IMAGE ) // Looking for image
  1144. {
  1145. UINT nIconId = 0;
  1146. if( pResultDataItem->nState & LVIS_SELECTED ) // Show the open image
  1147. {
  1148. nIconId = pItem->GetOpenIconId();
  1149. }
  1150. else // show the regular image
  1151. {
  1152. nIconId = pItem->GetIconId();
  1153. }
  1154. int iIndex = pThis->GetIconIndex(nIconId);
  1155. ASSERT(iIndex != -1);
  1156. pResultDataItem->nImage = iIndex;
  1157. }
  1158. }
  1159. else // for the results pane items
  1160. {
  1161. CResultsPaneItem* pItem = (CResultsPaneItem*)pResultDataItem->lParam;
  1162. if( ! CHECKOBJPTR(pItem,RUNTIME_CLASS(CResultsPaneItem),sizeof(CResultsPaneItem)) )
  1163. {
  1164. TRACE(_T("FAILED : Invalid lParam in RESULTDATAITEM struct.\n"));
  1165. return E_FAIL;
  1166. }
  1167. if( pResultDataItem->mask & RDI_STR )
  1168. {
  1169. pResultDataItem->str = (LPTSTR)(LPCTSTR)pItem->GetDisplayName(pResultDataItem->nCol);
  1170. }
  1171. if( pResultDataItem->mask & RDI_IMAGE ) // Looking for image
  1172. {
  1173. UINT nIconId = pItem->GetIconId();
  1174. int iIndex = pThis->GetIconIndex(nIconId);
  1175. ASSERT(iIndex != -1);
  1176. pResultDataItem->nImage = iIndex;
  1177. }
  1178. }
  1179. return S_OK;
  1180. }
  1181. HRESULT FAR EXPORT CResultsPane::XComponent::CompareObjects(
  1182. /* [in] */ LPDATAOBJECT lpDataObjectA,
  1183. /* [in] */ LPDATAOBJECT lpDataObjectB)
  1184. {
  1185. METHOD_PROLOGUE(CResultsPane, Component)
  1186. TRACEX(_T("CResultsPane::XComponent::CompareObjects\n"));
  1187. TRACEARGn(lpDataObjectA);
  1188. TRACEARGn(lpDataObjectB);
  1189. CSnapinDataObject* psdo1 = CSnapinDataObject::GetSnapinDataObject(lpDataObjectA);
  1190. if( ! CHECKOBJPTR(psdo1,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  1191. {
  1192. return E_FAIL;
  1193. }
  1194. CSnapinDataObject* psdo2 = CSnapinDataObject::GetSnapinDataObject(lpDataObjectB);
  1195. if( ! CHECKOBJPTR(psdo2,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  1196. {
  1197. return E_FAIL;
  1198. }
  1199. if( psdo1->GetCookie() != psdo2->GetCookie() )
  1200. return S_FALSE;
  1201. return S_OK;
  1202. }
  1203. // IComponent Interface Part
  1204. /////////////////////////////////////////////////////////////////////////////
  1205. /////////////////////////////////////////////////////////////////////////////
  1206. // IResultDataCompare Interface Part
  1207. ULONG FAR EXPORT CResultsPane::XResultDataCompare::AddRef()
  1208. {
  1209. METHOD_PROLOGUE(CResultsPane, ResultDataCompare)
  1210. return pThis->ExternalAddRef();
  1211. }
  1212. ULONG FAR EXPORT CResultsPane::XResultDataCompare::Release()
  1213. {
  1214. METHOD_PROLOGUE(CResultsPane, ResultDataCompare)
  1215. return pThis->ExternalRelease();
  1216. }
  1217. HRESULT FAR EXPORT CResultsPane::XResultDataCompare::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  1218. {
  1219. METHOD_PROLOGUE(CResultsPane, ResultDataCompare)
  1220. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  1221. }
  1222. HRESULT FAR EXPORT CResultsPane::XResultDataCompare::Compare(
  1223. /* [in] */ LPARAM lUserParam,
  1224. /* [in] */ MMC_COOKIE cookieA,
  1225. /* [in] */ MMC_COOKIE cookieB,
  1226. /* [out][in] */ int __RPC_FAR *pnResult)
  1227. {
  1228. METHOD_PROLOGUE(CResultsPane, ResultDataCompare)
  1229. TRACEX(_T("CResultsPane::XResultDataCompare::Compare\n"));
  1230. TRACEARGn(lUserParam);
  1231. TRACEARGn(cookieA);
  1232. TRACEARGn(cookieB);
  1233. TRACEARGn(pnResult);
  1234. HRESULT hr = S_OK;
  1235. CResultsPaneItem* pItem1 = (CResultsPaneItem*)cookieA;
  1236. if( ! CHECKOBJPTR(pItem1,RUNTIME_CLASS(CResultsPaneItem),sizeof(CResultsPaneItem)) )
  1237. {
  1238. return E_FAIL;
  1239. }
  1240. CResultsPaneItem* pItem2 = (CResultsPaneItem*)cookieB;
  1241. if( ! CHECKOBJPTR(pItem2,RUNTIME_CLASS(CResultsPaneItem),sizeof(CResultsPaneItem)) )
  1242. {
  1243. return E_FAIL;
  1244. }
  1245. int iColumn = *pnResult;
  1246. *pnResult = pItem1->CompareItem(pItem2,iColumn);
  1247. return hr;
  1248. }
  1249. // IResultDataCompare Interface Part
  1250. /////////////////////////////////////////////////////////////////////////////
  1251. /////////////////////////////////////////////////////////////////////////////
  1252. // IExtendContextMenu Interface Part
  1253. ULONG FAR EXPORT CResultsPane::XExtendContextMenu::AddRef()
  1254. {
  1255. METHOD_PROLOGUE(CResultsPane, ExtendContextMenu)
  1256. return pThis->ExternalAddRef();
  1257. }
  1258. ULONG FAR EXPORT CResultsPane::XExtendContextMenu::Release()
  1259. {
  1260. METHOD_PROLOGUE(CResultsPane, ExtendContextMenu)
  1261. return pThis->ExternalRelease();
  1262. }
  1263. HRESULT FAR EXPORT CResultsPane::XExtendContextMenu::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  1264. {
  1265. METHOD_PROLOGUE(CResultsPane, ExtendContextMenu)
  1266. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  1267. }
  1268. HRESULT FAR EXPORT CResultsPane::XExtendContextMenu::AddMenuItems(
  1269. /* [in] */ LPDATAOBJECT piDataObject,
  1270. /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
  1271. /* [out][in] */ long __RPC_FAR *pInsertionAllowed)
  1272. {
  1273. METHOD_PROLOGUE(CResultsPane, ExtendContextMenu)
  1274. TRACEX(_T("CResultsPane::XExtendContextMenu::AddMenuItems\n"));
  1275. TRACEARGn(piDataObject);
  1276. TRACEARGn(piCallback);
  1277. TRACEARGn(pInsertionAllowed);
  1278. HRESULT hr = S_OK;
  1279. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(piDataObject);
  1280. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  1281. {
  1282. return E_FAIL;
  1283. }
  1284. if( ! CHECKPTR(piCallback,sizeof(IContextMenuCallback)) )
  1285. {
  1286. return E_FAIL;
  1287. }
  1288. DATA_OBJECT_TYPES Type = psdo->GetItemType();
  1289. if( Type == CCT_SCOPE )
  1290. {
  1291. CScopePaneItem* pItem = NULL;
  1292. if( ! psdo->GetItem(pItem) )
  1293. {
  1294. return E_FAIL;
  1295. }
  1296. hr = pItem->OnAddMenuItems(piCallback,pInsertionAllowed);
  1297. if( ! CHECKHRESULT(hr) )
  1298. {
  1299. TRACE(_T("FAILED : CScopePaneItem::OnAddMenuItem failed.\n"));
  1300. }
  1301. }
  1302. else if( Type == CCT_RESULT )
  1303. {
  1304. CResultsPaneItem* pItem = NULL;
  1305. if( ! psdo->GetItem(pItem) )
  1306. {
  1307. return E_FAIL;
  1308. }
  1309. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  1310. hr = pView->OnAddMenuItems(pItem,piCallback,pInsertionAllowed);
  1311. if( ! CHECKHRESULT(hr) )
  1312. {
  1313. TRACE(_T("FAILED : CResultsPaneView::OnAddMenuItem failed!\n"));
  1314. }
  1315. }
  1316. return hr;
  1317. }
  1318. HRESULT FAR EXPORT CResultsPane::XExtendContextMenu::Command(
  1319. /* [in] */ long lCommandID,
  1320. /* [in] */ LPDATAOBJECT piDataObject)
  1321. {
  1322. METHOD_PROLOGUE(CResultsPane, ExtendContextMenu)
  1323. TRACEX(_T("CResultsPane::XExtendContextMenu::Command\n"));
  1324. TRACEARGn(lCommandID);
  1325. TRACEARGn(piDataObject);
  1326. HRESULT hr = S_OK;
  1327. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(piDataObject);
  1328. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  1329. {
  1330. return E_FAIL;
  1331. }
  1332. DATA_OBJECT_TYPES Type = psdo->GetItemType();
  1333. if( Type == CCT_SCOPE )
  1334. {
  1335. CScopePaneItem* pItem = NULL;
  1336. if( ! psdo->GetItem(pItem) )
  1337. {
  1338. return E_FAIL;
  1339. }
  1340. hr = pItem->OnCommand(lCommandID);
  1341. if( ! CHECKHRESULT(hr) )
  1342. {
  1343. TRACE(_T("FAILED : CScopePaneItem::OnCommand failed.\n"));
  1344. }
  1345. }
  1346. else if( Type == CCT_RESULT )
  1347. {
  1348. CResultsPaneItem* pItem = NULL;
  1349. if( ! psdo->GetItem(pItem) )
  1350. {
  1351. return E_FAIL;
  1352. }
  1353. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  1354. hr = pView->OnCommand(pThis,pItem,lCommandID);
  1355. if( ! CHECKHRESULT(hr) )
  1356. {
  1357. TRACE(_T("FAILED : CResultsPaneView::OnCommand failed!\n"));
  1358. }
  1359. }
  1360. return hr;
  1361. }
  1362. // IExtendContextMenu Interface Part
  1363. /////////////////////////////////////////////////////////////////////////////
  1364. /////////////////////////////////////////////////////////////////////////////
  1365. // IExtendPropertySheet2 Interface Part
  1366. ULONG FAR EXPORT CResultsPane::XExtendPropertySheet2::AddRef()
  1367. {
  1368. METHOD_PROLOGUE(CResultsPane, ExtendPropertySheet2)
  1369. return pThis->ExternalAddRef();
  1370. }
  1371. ULONG FAR EXPORT CResultsPane::XExtendPropertySheet2::Release()
  1372. {
  1373. METHOD_PROLOGUE(CResultsPane, ExtendPropertySheet2)
  1374. return pThis->ExternalRelease();
  1375. }
  1376. HRESULT FAR EXPORT CResultsPane::XExtendPropertySheet2::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  1377. {
  1378. METHOD_PROLOGUE(CResultsPane, ExtendPropertySheet2)
  1379. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  1380. }
  1381. HRESULT FAR EXPORT CResultsPane::XExtendPropertySheet2::CreatePropertyPages(
  1382. /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
  1383. /* [in] */ LONG_PTR handle,
  1384. /* [in] */ LPDATAOBJECT lpIDataObject)
  1385. {
  1386. METHOD_PROLOGUE(CResultsPane, ExtendPropertySheet2)
  1387. TRACEX(_T("CResultsPane::XExtendPropertySheet2::CreatePropertyPages\n"));
  1388. TRACEARGn(lpProvider);
  1389. TRACEARGn(handle);
  1390. TRACEARGn(lpIDataObject);
  1391. HRESULT hr = S_FALSE;
  1392. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpIDataObject);
  1393. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  1394. {
  1395. return E_FAIL;
  1396. }
  1397. if( ! CHECKPTR(lpProvider,sizeof(IPropertySheetCallback)) )
  1398. {
  1399. return E_FAIL;
  1400. }
  1401. DATA_OBJECT_TYPES Type = psdo->GetItemType();
  1402. if( Type == CCT_SCOPE )
  1403. {
  1404. CScopePaneItem* pItem = NULL;
  1405. if( ! psdo->GetItem(pItem) )
  1406. {
  1407. return E_FAIL;
  1408. }
  1409. hr = pItem->OnCreatePropertyPages(lpProvider,handle);
  1410. if( ! CHECKHRESULT(hr) )
  1411. {
  1412. TRACE(_T("FAILED : CScopePaneItem::OnCreatePropertyPages failed.\n"));
  1413. }
  1414. }
  1415. else if( Type == CCT_RESULT )
  1416. {
  1417. CResultsPaneItem* pItem = NULL;
  1418. if( ! psdo->GetItem(pItem) )
  1419. {
  1420. return E_FAIL;
  1421. }
  1422. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  1423. hr = pView->OnCreatePropertyPages(pItem,lpProvider,handle);
  1424. if( ! CHECKHRESULT(hr) )
  1425. {
  1426. TRACE(_T("FAILED : CResultsPaneView::OnCreatePropertyPages failed!\n"));
  1427. }
  1428. }
  1429. return hr;
  1430. }
  1431. HRESULT FAR EXPORT CResultsPane::XExtendPropertySheet2::QueryPagesFor(
  1432. /* [in] */ LPDATAOBJECT lpDataObject)
  1433. {
  1434. METHOD_PROLOGUE(CResultsPane, ExtendPropertySheet2)
  1435. TRACEX(_T("CResultsPane::XExtendPropertySheet2::QueryPagesFor\n"));
  1436. TRACEARGn(lpDataObject);
  1437. HRESULT hr = S_OK;
  1438. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  1439. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  1440. {
  1441. return E_FAIL;
  1442. }
  1443. DATA_OBJECT_TYPES Type = psdo->GetItemType();
  1444. if( Type == CCT_SCOPE )
  1445. {
  1446. CScopePaneItem* pItem = NULL;
  1447. if( ! psdo->GetItem(pItem) )
  1448. {
  1449. return E_FAIL;
  1450. }
  1451. hr = pItem->OnQueryPagesFor();
  1452. if( ! CHECKHRESULT(hr) )
  1453. {
  1454. TRACE(_T("FAILED : CScopePaneItem::OnQueryPagesFor failed.\n"));
  1455. }
  1456. }
  1457. else if( Type == CCT_RESULT )
  1458. {
  1459. CResultsPaneItem* pItem = NULL;
  1460. if( ! psdo->GetItem(pItem) )
  1461. {
  1462. return E_FAIL;
  1463. }
  1464. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  1465. hr = pView->OnQueryPagesFor(pItem);
  1466. if( ! CHECKHRESULT(hr) )
  1467. {
  1468. TRACE(_T("FAILED : CResultsPaneView::OnQueryPagesFor failed!\n"));
  1469. }
  1470. }
  1471. return hr;
  1472. }
  1473. HRESULT FAR EXPORT CResultsPane::XExtendPropertySheet2::GetWatermarks(
  1474. /* [in] */ LPDATAOBJECT lpIDataObject,
  1475. /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
  1476. /* [out] */ HBITMAP __RPC_FAR *lphHeader,
  1477. /* [out] */ HPALETTE __RPC_FAR *lphPalette,
  1478. /* [out] */ BOOL __RPC_FAR *bStretch)
  1479. {
  1480. METHOD_PROLOGUE(CResultsPane, ExtendPropertySheet2)
  1481. TRACEX(_T("CResultsPane::XExtendPropertySheet2::GetWatermarks\n"));
  1482. TRACEARGn(lpIDataObject);
  1483. TRACEARGn(lphWatermark);
  1484. TRACEARGn(lphHeader);
  1485. TRACEARGn(lphPalette);
  1486. TRACEARGn(bStretch);
  1487. HRESULT hr = S_OK;
  1488. return hr;
  1489. }
  1490. // IExtendPropertySheet2 Interface Part
  1491. /////////////////////////////////////////////////////////////////////////////
  1492. /////////////////////////////////////////////////////////////////////////////
  1493. // IExtendControlbar Interface Part
  1494. ULONG FAR EXPORT CResultsPane::XExtendControlbar::AddRef()
  1495. {
  1496. METHOD_PROLOGUE(CResultsPane, ExtendControlbar)
  1497. return pThis->ExternalAddRef();
  1498. }
  1499. ULONG FAR EXPORT CResultsPane::XExtendControlbar::Release()
  1500. {
  1501. METHOD_PROLOGUE(CResultsPane, ExtendControlbar)
  1502. return pThis->ExternalRelease();
  1503. }
  1504. HRESULT FAR EXPORT CResultsPane::XExtendControlbar::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  1505. {
  1506. METHOD_PROLOGUE(CResultsPane, ExtendControlbar)
  1507. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  1508. }
  1509. HRESULT FAR EXPORT CResultsPane::XExtendControlbar::SetControlbar(
  1510. /* [in] */ LPCONTROLBAR pControlbar)
  1511. {
  1512. METHOD_PROLOGUE(CResultsPane, ExtendControlbar)
  1513. TRACEX(_T("CResultsPane::XExtendControlbar::SetControlbar\n"));
  1514. TRACEARGn(pControlbar);
  1515. HRESULT hr = pThis->OnSetControlbar(pControlbar);
  1516. if( ! CHECKHRESULT(hr) )
  1517. {
  1518. TRACE(_T("WARNING : CResultsPane::OnSetControlbar failed.\n"));
  1519. }
  1520. return hr;
  1521. }
  1522. HRESULT FAR EXPORT CResultsPane::XExtendControlbar::ControlbarNotify(
  1523. /* [in] */ MMC_NOTIFY_TYPE event,
  1524. /* [in] */ LPARAM arg,
  1525. /* [in] */ LPARAM param)
  1526. {
  1527. METHOD_PROLOGUE(CResultsPane, ExtendControlbar)
  1528. TRACEX(_T("CResultsPane::XExtendControlbar::ControlbarNotify\n"));
  1529. TRACEARGn(event);
  1530. TRACEARGn(arg);
  1531. TRACEARGn(param);
  1532. HRESULT hr = S_OK;
  1533. hr = pThis->OnControlbarNotify(event,arg,param);
  1534. if( ! CHECKHRESULT(hr) )
  1535. {
  1536. TRACE(_T("WARNING : CResultsPane::OnControlbarNotify returned error code.\n"));
  1537. }
  1538. return hr;
  1539. }
  1540. // IExtendControlbar Interface Part
  1541. /////////////////////////////////////////////////////////////////////////////