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.

1574 lines
34 KiB

  1. // ScopePane.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ScopePane.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CScopePane
  12. IMPLEMENT_DYNCREATE(CScopePane, CCmdTarget)
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Construction/Destruction
  15. /////////////////////////////////////////////////////////////////////////////
  16. CScopePane::CScopePane()
  17. {
  18. EnableAutomation();
  19. m_pRootItem = NULL;
  20. m_pMsgHook = NULL;
  21. m_pIConsoleNamespace = NULL;
  22. m_pIConsole = NULL;
  23. m_pIImageList = NULL;
  24. m_pSelectedScopeItem = NULL;
  25. // To keep the application running as long as an OLE automation
  26. // object is active, the constructor calls AfxOleLockApp.
  27. AfxOleLockApp();
  28. }
  29. CScopePane::~CScopePane()
  30. {
  31. // To terminate the application when all objects created with
  32. // with OLE automation, the destructor calls AfxOleUnlockApp.
  33. AfxOleUnlockApp();
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. // Creation/Destruction Overrideable Members
  37. /////////////////////////////////////////////////////////////////////////////
  38. bool CScopePane::OnCreate()
  39. {
  40. TRACEX(_T("CScopePane::OnCreate\n"));
  41. if( ! GetRootScopeItem() )
  42. {
  43. TRACE(_T("FAILED : The pointer to the root item is invalid.\n"));
  44. return false;
  45. }
  46. if( ! m_pRootItem->Create(this,NULL) )
  47. {
  48. TRACE(_T("CRootScopeItem::Create failed.\n"));
  49. return false;
  50. }
  51. return true;
  52. }
  53. LPCOMPONENT CScopePane::OnCreateComponent()
  54. {
  55. TRACEX(_T("CScopePane::OnCreateComponent\n"));
  56. CResultsPane* pNewPane = new CResultsPane;
  57. if( ! CHECKOBJPTR(pNewPane,RUNTIME_CLASS(CResultsPane),sizeof(CResultsPane)) )
  58. {
  59. TRACE(_T("FAILED : Out of memory.\n"));
  60. return NULL;
  61. }
  62. pNewPane->SetOwnerScopePane(this);
  63. int iIndex = AddResultsPane(pNewPane);
  64. ASSERT(iIndex != -1);
  65. LPCOMPONENT pComponent = (LPCOMPONENT)pNewPane->GetInterface(&IID_IComponent);
  66. if( ! CHECKPTR(pComponent,sizeof(IComponent)) )
  67. {
  68. return NULL;
  69. }
  70. return pComponent;
  71. }
  72. bool CScopePane::OnDestroy()
  73. {
  74. TRACEX(_T("CScopePane::OnDestroy\n"));
  75. // unhook the window first
  76. UnhookWindow();
  77. if( m_pMsgHook )
  78. {
  79. delete m_pMsgHook;
  80. m_pMsgHook = NULL;
  81. }
  82. // delete the root scope pane item
  83. CScopePaneItem* pRootItem = GetRootScopeItem();
  84. if( pRootItem )
  85. {
  86. delete pRootItem;
  87. m_pRootItem = NULL;
  88. }
  89. // Release all the interfaces queried for
  90. if( m_pIConsole )
  91. {
  92. m_pIConsole->Release();
  93. m_pIConsole = NULL;
  94. }
  95. if( m_pIConsoleNamespace )
  96. {
  97. m_pIConsoleNamespace->Release();
  98. m_pIConsoleNamespace = NULL;
  99. }
  100. if( m_pIImageList )
  101. {
  102. m_pIImageList->Release();
  103. m_pIImageList = NULL;
  104. }
  105. // empty Result Panes array
  106. for( int i = GetResultsPaneCount()-1; i >= 0; i-- )
  107. {
  108. RemoveResultsPane(i);
  109. }
  110. m_pSelectedScopeItem = NULL;
  111. return true;
  112. }
  113. /////////////////////////////////////////////////////////////////////////////
  114. // Root Scope Pane Item Members
  115. /////////////////////////////////////////////////////////////////////////////
  116. CScopePaneItem* CScopePane::CreateRootScopeItem()
  117. {
  118. TRACEX(_T("CScopePane::CreateRootScopeItem\n"));
  119. return NULL;
  120. }
  121. CScopePaneItem* CScopePane::GetRootScopeItem()
  122. {
  123. TRACEX(_T("CScopePane::GetRootScopeItem\n"));
  124. if( ! CHECKOBJPTR(m_pRootItem,RUNTIME_CLASS(CScopePaneItem),sizeof(CScopePaneItem)) )
  125. {
  126. return NULL;
  127. }
  128. return m_pRootItem;
  129. }
  130. void CScopePane::SetRootScopeItem(CScopePaneItem* pRootItem)
  131. {
  132. TRACEX(_T("CScopePane::GetRootScopeItem\n"));
  133. if( ! CHECKOBJPTR(pRootItem,RUNTIME_CLASS(CScopePaneItem),sizeof(CScopePaneItem)) )
  134. {
  135. return;
  136. }
  137. m_pRootItem = pRootItem;
  138. }
  139. /////////////////////////////////////////////////////////////////////////////
  140. // MMC Frame Window Message Hook Members
  141. /////////////////////////////////////////////////////////////////////////////
  142. bool CScopePane::HookWindow()
  143. {
  144. TRACEX(_T("CScopePane::HookWindow\n"));
  145. if( m_pMsgHook == NULL )
  146. {
  147. m_pMsgHook = new CMmcMsgHook;
  148. }
  149. if( ! CHECKOBJPTR(m_pMsgHook,RUNTIME_CLASS(CMmcMsgHook),sizeof(CMmcMsgHook)) )
  150. {
  151. return false;
  152. }
  153. HWND hMMCMainWnd = NULL;
  154. LPCONSOLE2 lpConsole = GetConsolePtr();
  155. if( lpConsole == NULL )
  156. {
  157. return false;
  158. }
  159. lpConsole->GetMainWindow(&hMMCMainWnd);
  160. m_pMsgHook->Init(GetRootScopeItem(),hMMCMainWnd);
  161. lpConsole->Release();
  162. return true;
  163. }
  164. void CScopePane::UnhookWindow()
  165. {
  166. TRACEX(_T("CScopePane::UnhookWindow\n"));
  167. if( ! CHECKOBJPTR(m_pMsgHook,RUNTIME_CLASS(CMmcMsgHook),sizeof(CMmcMsgHook)) )
  168. {
  169. return;
  170. }
  171. m_pMsgHook->HookWindow(NULL);
  172. }
  173. /////////////////////////////////////////////////////////////////////////////
  174. // MMC Interface Members
  175. /////////////////////////////////////////////////////////////////////////////
  176. LPCONSOLENAMESPACE2 CScopePane::GetConsoleNamespacePtr()
  177. {
  178. TRACEX(_T("CScopePane::GetConsoleNamespacePtr\n"));
  179. if( ! CHECKPTR(m_pIConsoleNamespace,sizeof(IConsoleNameSpace2)) )
  180. {
  181. return NULL;
  182. }
  183. m_pIConsoleNamespace->AddRef();
  184. return m_pIConsoleNamespace;
  185. }
  186. LPCONSOLE2 CScopePane::GetConsolePtr()
  187. {
  188. TRACEX(_T("CScopePane::GetConsolePtr\n"));
  189. if( ! CHECKPTR(m_pIConsole,sizeof(IConsole2)) )
  190. {
  191. return NULL;
  192. }
  193. m_pIConsole->AddRef();
  194. return m_pIConsole;
  195. }
  196. LPIMAGELIST CScopePane::GetImageListPtr()
  197. {
  198. TRACEX(_T("CScopePane::GetImageListPtr\n"));
  199. if( ! CHECKPTR(m_pIImageList,sizeof(IImageList)) )
  200. {
  201. return NULL;
  202. }
  203. m_pIImageList->AddRef();
  204. return m_pIImageList;
  205. }
  206. LPUNKNOWN CScopePane::GetCustomOcxPtr()
  207. {
  208. TRACEX(_T("CScopePane::GetCustomOcxPtr\n"));
  209. LPCONSOLE2 pIConsole = GetConsolePtr();
  210. if( ! CHECKPTR(pIConsole,sizeof(IConsole)) )
  211. {
  212. return NULL;
  213. }
  214. LPUNKNOWN pIUnknown = NULL;
  215. HRESULT hr = pIConsole->QueryResultView(&pIUnknown);
  216. if( ! CHECKHRESULT(hr) )
  217. {
  218. return NULL;
  219. }
  220. pIConsole->Release();
  221. return pIUnknown;
  222. }
  223. /////////////////////////////////////////////////////////////////////////////
  224. // MMC Scope Pane Helper Members
  225. /////////////////////////////////////////////////////////////////////////////
  226. CScopePaneItem* CScopePane::GetSelectedScopeItem()
  227. {
  228. TRACEX(_T("CScopePane::GetSelectedScopeItem\n"));
  229. if( ! m_pSelectedScopeItem )
  230. {
  231. TRACE(_T("WARNING : Selected Scope Item is NULL.\n"));
  232. return NULL;
  233. }
  234. if( ! GfxCheckObjPtr(m_pSelectedScopeItem,CScopePaneItem) )
  235. {
  236. TRACE(_T("FAILED : m_pSelectedScopeItem is not valid.\n"));
  237. return NULL;
  238. }
  239. return m_pSelectedScopeItem;
  240. }
  241. void CScopePane::SetSelectedScopeItem(CScopePaneItem* pItem)
  242. {
  243. TRACEX(_T("CScopePane::SetSelectedScopeItem\n"));
  244. TRACEARGn(pItem);
  245. if( ! pItem )
  246. {
  247. m_pSelectedScopeItem = NULL;
  248. return;
  249. }
  250. if( ! GfxCheckObjPtr(pItem,CScopePaneItem) )
  251. {
  252. TRACE(_T("FAILED : pItem pointer is invalid.\n"));
  253. return;
  254. }
  255. m_pSelectedScopeItem = pItem;
  256. }
  257. /////////////////////////////////////////////////////////////////////////////
  258. // Scope Item Icon Management
  259. /////////////////////////////////////////////////////////////////////////////
  260. int CScopePane::AddIcon(UINT nIconResID)
  261. {
  262. TRACEX(_T("CScopePane::AddIcon\n"));
  263. TRACEARGn(nIconResID);
  264. if( ! CHECKPTR(m_pIImageList,sizeof(IImageList)) )
  265. {
  266. return -1;
  267. }
  268. int nIconIndex = GetIconIndex(nIconResID);
  269. if( nIconIndex != -1 )
  270. {
  271. return nIconIndex;
  272. }
  273. // load icon
  274. HICON hIcon = AfxGetApp()->LoadIcon(nIconResID);
  275. if( hIcon == NULL )
  276. {
  277. TRACE(_T("FAILED : Icon with resid=%d not found"),nIconResID);
  278. return -1;
  279. }
  280. nIconIndex = GetIconCount();
  281. // insert icon into image list
  282. #ifndef IA64
  283. if( ! CHECKHRESULT(m_pIImageList->ImageListSetIcon((long*)hIcon, nIconIndex)) )
  284. {
  285. return -1;
  286. }
  287. #endif // IA64
  288. // add resid and index to map
  289. m_IconMap.SetAt(nIconResID,nIconIndex);
  290. // return index of newly inserted image
  291. return nIconIndex;
  292. }
  293. int CScopePane::GetIconIndex(UINT nIconResID)
  294. {
  295. TRACEX(_T("CScopePane::GetIconIndex\n"));
  296. TRACEARGn(nIconResID);
  297. if( ! CHECKPTR(m_pIImageList,sizeof(IImageList)) )
  298. {
  299. return -1;
  300. }
  301. // check map for an existing id
  302. int nIconIndex = -1;
  303. if( m_IconMap.Lookup(nIconResID,nIconIndex) )
  304. {
  305. // if exists, return index
  306. return nIconIndex;
  307. }
  308. TRACE(_T("FAILED : Icon could not be found with Resource id=%d\n"),nIconResID);
  309. return -1;
  310. }
  311. int CScopePane::GetIconCount()
  312. {
  313. TRACEX(_T("CScopePane::GetIconCount\n"));
  314. return (int)m_IconMap.GetCount();
  315. }
  316. void CScopePane::RemoveAllIcons()
  317. {
  318. TRACEX(_T("CScopePane::RemoveAllIcons\n"));
  319. m_IconMap.RemoveAll();
  320. }
  321. /////////////////////////////////////////////////////////////////////////////
  322. // Results Pane Members
  323. /////////////////////////////////////////////////////////////////////////////
  324. int CScopePane::GetResultsPaneCount() const
  325. {
  326. TRACEX(_T("CScopePane::GetResultsPaneCount\n"));
  327. return (int)m_ResultsPanes.GetSize();
  328. }
  329. CResultsPane* CScopePane::GetResultsPane(int iIndex)
  330. {
  331. TRACEX(_T("CScopePane::GetResultsPaneCount\n"));
  332. TRACEARGn(iIndex);
  333. if( iIndex >= m_ResultsPanes.GetSize() || iIndex < 0 )
  334. {
  335. TRACE(_T("FAILED : Requested ResultPane is out of array bounds\n"));
  336. return NULL;
  337. }
  338. CResultsPane* pPane = m_ResultsPanes[iIndex];
  339. if( ! CHECKOBJPTR(pPane,RUNTIME_CLASS(CResultsPane),sizeof(CResultsPane)) )
  340. {
  341. return NULL;
  342. }
  343. return pPane;
  344. }
  345. int CScopePane::AddResultsPane(CResultsPane* pPane)
  346. {
  347. TRACEX(_T("CScopePane::AddResultsPane\n"));
  348. TRACEARGn(pPane);
  349. if( ! CHECKOBJPTR(pPane,RUNTIME_CLASS(CResultsPane),sizeof(CResultsPane)) )
  350. {
  351. TRACE(_T("FAILED : pPane pointer is invalid.\n"));
  352. return -1;
  353. }
  354. pPane->ExternalAddRef();
  355. return (int)m_ResultsPanes.Add(pPane);
  356. }
  357. void CScopePane::RemoveResultsPane(int iIndex)
  358. {
  359. TRACEX(_T("CScopePane::RemoveResultsPane\n"));
  360. TRACEARGn(iIndex);
  361. if( iIndex >= m_ResultsPanes.GetSize() || iIndex < 0 )
  362. {
  363. TRACE(_T("FAILED : Requested ResultPane is out of array bounds\n"));
  364. return;
  365. }
  366. CResultsPane* pPane = m_ResultsPanes[iIndex];
  367. m_ResultsPanes.RemoveAt(iIndex);
  368. pPane->ExternalRelease();
  369. }
  370. /////////////////////////////////////////////////////////////////////////////
  371. // Serialization
  372. /////////////////////////////////////////////////////////////////////////////
  373. bool CScopePane::OnLoad(CArchive& ar)
  374. {
  375. TRACEX(_T("CScopePane::OnLoad\n"));
  376. ASSERT(ar.IsLoading());
  377. return true;
  378. }
  379. bool CScopePane::OnSave(CArchive& ar)
  380. {
  381. TRACEX(_T("CScopePane::OnSave\n"));
  382. ASSERT(ar.IsStoring());
  383. return true;
  384. }
  385. /////////////////////////////////////////////////////////////////////////////
  386. // MMC Help
  387. /////////////////////////////////////////////////////////////////////////////
  388. bool CScopePane::ShowTopic(const CString& sHelpTopic)
  389. {
  390. TRACEX(_T("CScopePane::ShowTopic\n"));
  391. if( sHelpTopic.IsEmpty() )
  392. {
  393. return false;
  394. }
  395. if( ! m_pIConsole )
  396. {
  397. return false;
  398. }
  399. IDisplayHelp* pIDisplayHelp = NULL;
  400. HRESULT hr = m_pIConsole->QueryInterface(IID_IDisplayHelp,(LPVOID*)&pIDisplayHelp);
  401. if( ! CHECKHRESULT(hr) )
  402. {
  403. return false;
  404. }
  405. CString sHTMLHelpTopic = AfxGetApp()->m_pszHelpFilePath;
  406. sHTMLHelpTopic = sHTMLHelpTopic + _T("::") + sHelpTopic;
  407. LPOLESTR lpCompiledHelpTopic = reinterpret_cast<LPOLESTR>(CoTaskMemAlloc((sHTMLHelpTopic.GetLength() + 1)* sizeof(wchar_t)));
  408. if(lpCompiledHelpTopic == NULL)
  409. {
  410. return false;
  411. }
  412. _tcscpy(lpCompiledHelpTopic, (LPCTSTR)sHTMLHelpTopic);
  413. hr = pIDisplayHelp->ShowTopic(lpCompiledHelpTopic);
  414. pIDisplayHelp->Release();
  415. if( ! CHECKHRESULT(hr) )
  416. {
  417. return false;
  418. }
  419. return true;
  420. }
  421. /////////////////////////////////////////////////////////////////////////////
  422. // MFC Operations
  423. /////////////////////////////////////////////////////////////////////////////
  424. void CScopePane::OnFinalRelease()
  425. {
  426. // When the last reference for an automation object is released
  427. // OnFinalRelease is called. The base class will automatically
  428. // deletes the object. Add additional cleanup required for your
  429. // object before calling the base class.
  430. CCmdTarget::OnFinalRelease();
  431. }
  432. BEGIN_MESSAGE_MAP(CScopePane, CCmdTarget)
  433. //{{AFX_MSG_MAP(CScopePane)
  434. // NOTE - the ClassWizard will add and remove mapping macros here.
  435. //}}AFX_MSG_MAP
  436. END_MESSAGE_MAP()
  437. BEGIN_DISPATCH_MAP(CScopePane, CCmdTarget)
  438. //{{AFX_DISPATCH_MAP(CScopePane)
  439. // NOTE - the ClassWizard will add and remove mapping macros here.
  440. //}}AFX_DISPATCH_MAP
  441. END_DISPATCH_MAP()
  442. // Note: we add support for IID_IScopePane to support typesafe binding
  443. // from VBA. This IID must match the GUID that is attached to the
  444. // dispinterface in the .ODL file.
  445. // {7D4A6858-9056-11D2-BD45-0000F87A3912}
  446. static const IID IID_IScopePane =
  447. { 0x7d4a6858, 0x9056, 0x11d2, { 0xbd, 0x45, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
  448. BEGIN_INTERFACE_MAP(CScopePane, CCmdTarget)
  449. INTERFACE_PART(CScopePane, IID_IScopePane, Dispatch)
  450. INTERFACE_PART(CScopePane, IID_IComponentData, ComponentData)
  451. INTERFACE_PART(CScopePane, IID_IPersistStream, PersistStream)
  452. INTERFACE_PART(CScopePane, IID_IExtendContextMenu, ExtendContextMenu)
  453. INTERFACE_PART(CScopePane, IID_IExtendPropertySheet2, ExtendPropertySheet2)
  454. INTERFACE_PART(CScopePane, IID_ISnapinHelp, SnapinHelp)
  455. END_INTERFACE_MAP()
  456. /////////////////////////////////////////////////////////////////////////////
  457. // IComponentData Interface Part
  458. ULONG FAR EXPORT CScopePane::XComponentData::AddRef()
  459. {
  460. METHOD_PROLOGUE(CScopePane, ComponentData)
  461. return pThis->ExternalAddRef();
  462. }
  463. ULONG FAR EXPORT CScopePane::XComponentData::Release()
  464. {
  465. METHOD_PROLOGUE(CScopePane, ComponentData)
  466. return pThis->ExternalRelease();
  467. }
  468. HRESULT FAR EXPORT CScopePane::XComponentData::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  469. {
  470. METHOD_PROLOGUE(CScopePane, ComponentData)
  471. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  472. }
  473. HRESULT FAR EXPORT CScopePane::XComponentData::Initialize(
  474. /* [in] */ LPUNKNOWN pUnknown)
  475. {
  476. METHOD_PROLOGUE(CScopePane, ComponentData)
  477. TRACEX(_T("CScopePane::XComponentData::Initialize\n"));
  478. TRACEARGn(pUnknown);
  479. if( ! CHECKPTR(pUnknown,sizeof(IUnknown)) )
  480. {
  481. return E_FAIL;
  482. }
  483. HRESULT hr = S_OK;
  484. // MMC should only call ::Initialize once! But you know those MMC clowns...
  485. ASSERT( pThis->m_pIConsoleNamespace == NULL );
  486. if( pThis->m_pIConsoleNamespace != NULL )
  487. {
  488. TRACE(_T("FAILED : IComponentData::Initialize has already been called. Returning with Error.\n"));
  489. return E_FAIL;
  490. }
  491. // Get pointer to name space interface
  492. hr = pUnknown->QueryInterface(IID_IConsoleNameSpace2, (LPVOID*)(&pThis->m_pIConsoleNamespace));
  493. if( ! CHECKHRESULT(hr) )
  494. {
  495. TRACE(_T("FAILED : pUnknown->QueryInterface for IID_IConsoleNameSpace2 failed.\n"));
  496. return hr;
  497. }
  498. // Get pointer to console interface
  499. hr = pUnknown->QueryInterface(IID_IConsole2, (LPVOID*)(&pThis->m_pIConsole));
  500. if( ! CHECKHRESULT(hr) )
  501. {
  502. TRACE(_T("FAILED : pUnknown->QueryInterface for IID_IConsole2 failed.\n"));
  503. return hr;
  504. }
  505. // Query for the Scope Pane ImageList Interface
  506. pThis->m_pIImageList = NULL;
  507. hr = pThis->m_pIConsole->QueryScopeImageList(&(pThis->m_pIImageList));
  508. if( ! CHECKHRESULT(hr) )
  509. {
  510. TRACE(_T("pUnknown->QueryScopeImageList failed.\n"));
  511. return hr;
  512. }
  513. // Call OnCreate for derived classes. Base class implementation creates a new root scope pane item.
  514. if( ! pThis->OnCreate() )
  515. {
  516. TRACE(_T("FAILED : CScopePane::OnCreate failed.\n"));
  517. return E_FAIL;
  518. }
  519. // Hook the MMC top level window to intercept any window messages of interest
  520. if( ! pThis->HookWindow() )
  521. {
  522. TRACE(_T("FAILED : Unable to hook MMC main window\n"));
  523. return E_FAIL;
  524. }
  525. return hr;
  526. }
  527. HRESULT FAR EXPORT CScopePane::XComponentData::CreateComponent(
  528. /* [out] */ LPCOMPONENT __RPC_FAR *ppComponent)
  529. {
  530. METHOD_PROLOGUE(CScopePane, ComponentData)
  531. TRACEX(_T("CScopePane::XComponentData::CreateComponent\n"));
  532. TRACEARGn(ppComponent);
  533. *ppComponent = pThis->OnCreateComponent();
  534. if( ! CHECKPTR(*ppComponent,sizeof(IComponent)) )
  535. {
  536. TRACE(_T("FAILED : OnCreateComponent returns invalid pointer.\n"));
  537. return E_FAIL;
  538. }
  539. return S_OK;
  540. }
  541. HRESULT FAR EXPORT CScopePane::XComponentData::Notify(
  542. /* [in] */ LPDATAOBJECT lpDataObject,
  543. /* [in] */ MMC_NOTIFY_TYPE event,
  544. /* [in] */ LPARAM arg,
  545. /* [in] */ LPARAM param)
  546. {
  547. METHOD_PROLOGUE(CScopePane, ComponentData)
  548. TRACEX(_T("CScopePane::XComponentData::Notify\n"));
  549. TRACEARGn(lpDataObject);
  550. TRACEARGn(event);
  551. TRACEARGn(arg);
  552. TRACEARGn(param);
  553. HRESULT hr = S_OK;
  554. switch( event )
  555. {
  556. case MMCN_BTN_CLICK: // toolbar button clicked
  557. {
  558. TRACE(_T("MMCN_BTN_CLICK received.\n"));
  559. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  560. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  561. {
  562. return E_FAIL;
  563. }
  564. if( psdo->GetItemType() == CCT_SCOPE )
  565. {
  566. CScopePaneItem* pItem = NULL;
  567. if( ! psdo->GetItem(pItem) )
  568. {
  569. return E_FAIL;
  570. }
  571. ASSERT(pItem);
  572. hr = pItem->OnBtnClick((MMC_CONSOLE_VERB)arg);
  573. }
  574. else if( psdo->GetItemType() == CCT_RESULT )
  575. {
  576. CResultsPaneItem* pItem = NULL;
  577. if( ! psdo->GetItem(pItem) )
  578. {
  579. return E_FAIL;
  580. }
  581. ASSERT(pItem);
  582. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  583. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  584. {
  585. return E_FAIL;
  586. }
  587. ASSERT(pView);
  588. hr = pView->OnBtnClick(pItem,(MMC_CONSOLE_VERB)arg);
  589. }
  590. }
  591. break;
  592. case MMCN_CONTEXTHELP: // F1, Help Menu Item or Help Button selected
  593. {
  594. TRACE(_T("MMCN_CONTEXTHELP received.\n"));
  595. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  596. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  597. {
  598. return E_FAIL;
  599. }
  600. if( psdo->GetItemType() == CCT_SCOPE )
  601. {
  602. CScopePaneItem* pItem = NULL;
  603. if( ! psdo->GetItem(pItem) )
  604. {
  605. return E_FAIL;
  606. }
  607. ASSERT(pItem);
  608. hr = pItem->OnContextHelp();
  609. }
  610. else if( psdo->GetItemType() == CCT_RESULT )
  611. {
  612. CResultsPaneItem* pItem = NULL;
  613. if( ! psdo->GetItem(pItem) )
  614. {
  615. return E_FAIL;
  616. }
  617. ASSERT(pItem);
  618. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  619. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  620. {
  621. return E_FAIL;
  622. }
  623. ASSERT(pView);
  624. hr = pView->OnContextHelp(pItem);
  625. }
  626. }
  627. break;
  628. case MMCN_DELETE: // delete selected
  629. {
  630. TRACE(_T("MMCN_DELETE received.\n"));
  631. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  632. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  633. {
  634. return E_FAIL;
  635. }
  636. if( psdo->GetItemType() == CCT_SCOPE )
  637. {
  638. CScopePaneItem* pItem = NULL;
  639. if( ! psdo->GetItem(pItem) )
  640. {
  641. return E_FAIL;
  642. }
  643. ASSERT(pItem);
  644. hr = pItem->OnDelete();
  645. }
  646. else if( psdo->GetItemType() == CCT_RESULT )
  647. {
  648. CResultsPaneItem* pItem = NULL;
  649. if( ! psdo->GetItem(pItem) )
  650. {
  651. return E_FAIL;
  652. }
  653. ASSERT(pItem);
  654. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  655. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  656. {
  657. return E_FAIL;
  658. }
  659. ASSERT(pView);
  660. hr = pView->OnDelete(pItem);
  661. }
  662. }
  663. break;
  664. case MMCN_EXPAND: // user clicks on a previously unexpanded node
  665. {
  666. TRACE(_T("MMCN_EXPAND received.\n"));
  667. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  668. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  669. {
  670. return E_FAIL;
  671. }
  672. if( psdo->GetItemType() == CCT_SCOPE )
  673. {
  674. CScopePaneItem* pItem = NULL;
  675. if( ! psdo->GetItem(pItem) )
  676. {
  677. return E_FAIL;
  678. }
  679. ASSERT(pItem);
  680. if( pItem == pThis->GetRootScopeItem() )
  681. {
  682. pItem->SetItemHandle((HSCOPEITEM)param);
  683. }
  684. hr = pItem->OnExpand((BOOL)arg);
  685. }
  686. }
  687. break;
  688. case MMCN_PRELOAD:
  689. {
  690. TRACE(_T("MMCN_PRELOAD received.\n"));
  691. TRACE(_T("MMCN_PRELOAD not implemented.\n"));
  692. }
  693. break;
  694. case MMCN_PRINT:
  695. {
  696. TRACE(_T("MMCN_PRINT received.\n"));
  697. TRACE(_T("MMCN_PRINT not implemented.\n"));
  698. }
  699. break;
  700. case MMCN_PROPERTY_CHANGE:
  701. {
  702. TRACE(_T("MMCN_PROPERTY_CHANGE received.\n"));
  703. TRACE(_T("MMCN_PROPERTY_CHANGE not implemented.\n"));
  704. }
  705. break;
  706. case MMCN_REFRESH:
  707. {
  708. TRACE(_T("MMCN_REFRESH received.\n"));
  709. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  710. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  711. {
  712. return E_FAIL;
  713. }
  714. if( psdo->GetItemType() == CCT_SCOPE )
  715. {
  716. CScopePaneItem* pItem = NULL;
  717. if( ! psdo->GetItem(pItem) )
  718. {
  719. return E_FAIL;
  720. }
  721. ASSERT(pItem);
  722. hr = pItem->OnRefresh();
  723. }
  724. else if( psdo->GetItemType() == CCT_RESULT )
  725. {
  726. CResultsPaneItem* pItem = NULL;
  727. if( ! psdo->GetItem(pItem) )
  728. {
  729. return E_FAIL;
  730. }
  731. ASSERT(pItem);
  732. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  733. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  734. {
  735. return E_FAIL;
  736. }
  737. ASSERT(pView);
  738. hr = pView->OnRefresh();
  739. }
  740. }
  741. break;
  742. case MMCN_REMOVE_CHILDREN:
  743. {
  744. TRACE(_T("MMCN_REMOVE_CHILDREN received.\n"));
  745. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  746. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  747. {
  748. return E_FAIL;
  749. }
  750. if( psdo->GetItemType() == CCT_SCOPE )
  751. {
  752. CScopePaneItem* pItem = NULL;
  753. if( ! psdo->GetItem(pItem) )
  754. {
  755. return E_FAIL;
  756. }
  757. ASSERT(pItem);
  758. hr = pItem->OnRemoveChildren();
  759. }
  760. }
  761. break;
  762. case MMCN_RENAME:
  763. {
  764. TRACE(_T("MMCN_RENAME received.\n"));
  765. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpDataObject);
  766. if( ! CHECKOBJPTR(psdo,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  767. {
  768. return E_FAIL;
  769. }
  770. if( psdo->GetItemType() == CCT_SCOPE )
  771. {
  772. CScopePaneItem* pItem = NULL;
  773. if( ! psdo->GetItem(pItem) )
  774. {
  775. return E_FAIL;
  776. }
  777. ASSERT(pItem);
  778. CString sNewName = (LPOLESTR)param;
  779. hr = pItem->OnRename(sNewName);
  780. }
  781. }
  782. break;
  783. }
  784. return hr;
  785. }
  786. HRESULT FAR EXPORT CScopePane::XComponentData::Destroy(void)
  787. {
  788. METHOD_PROLOGUE(CScopePane, ComponentData)
  789. TRACEX(_T("CScopePane::XComponentData::Destroy\n"));
  790. if( ! pThis->OnDestroy() )
  791. {
  792. return E_FAIL;
  793. }
  794. return S_OK;
  795. }
  796. HRESULT FAR EXPORT CScopePane::XComponentData::QueryDataObject(
  797. /* [in] */ MMC_COOKIE cookie,
  798. /* [in] */ DATA_OBJECT_TYPES type,
  799. /* [out] */ LPDATAOBJECT __RPC_FAR *ppDataObject)
  800. {
  801. METHOD_PROLOGUE(CScopePane, ComponentData)
  802. TRACEX(_T("CScopePane::XComponentData::QueryDataObject\n"));
  803. TRACEARGn(cookie);
  804. TRACEARGn(type);
  805. TRACEARGn(ppDataObject);
  806. HRESULT hr = S_OK;
  807. CSnapinDataObject* pdoNew = NULL;
  808. pdoNew = new CSnapinDataObject;
  809. if( ! pdoNew )
  810. {
  811. hr = E_OUTOFMEMORY;
  812. *ppDataObject = NULL;
  813. TRACE(_T("Out of memory.\n"));
  814. return hr;
  815. }
  816. *ppDataObject = (LPDATAOBJECT)pdoNew->GetInterface(&IID_IDataObject);
  817. if( ! CHECKOBJPTR(pdoNew,RUNTIME_CLASS(CSnapinDataObject),sizeof(CSnapinDataObject)) )
  818. {
  819. return E_FAIL;
  820. }
  821. if( cookie )
  822. {
  823. CScopePaneItem* pItem = (CScopePaneItem*)cookie;
  824. if( ! CHECKOBJPTR(pItem,RUNTIME_CLASS(CScopePaneItem),sizeof(CScopePaneItem)) )
  825. {
  826. return E_FAIL;
  827. }
  828. pdoNew->SetItem(pItem);
  829. ASSERT(pdoNew->GetItemType() == CCT_SCOPE);
  830. }
  831. else // In this case the node is our root scope item, and was placed there for us by MMC.
  832. {
  833. pdoNew->SetItem( pThis->GetRootScopeItem() );
  834. ASSERT(pdoNew->GetItemType() == CCT_SCOPE);
  835. }
  836. return hr;
  837. }
  838. HRESULT FAR EXPORT CScopePane::XComponentData::GetDisplayInfo(
  839. /* [out][in] */ SCOPEDATAITEM __RPC_FAR *pScopeDataItem)
  840. {
  841. METHOD_PROLOGUE(CScopePane, ComponentData)
  842. TRACEX(_T("CScopePane::XComponentData::GetDisplayInfo\n"));
  843. TRACEARGn(pScopeDataItem);
  844. if( ! CHECKPTR(pScopeDataItem,sizeof(SCOPEDATAITEM)) )
  845. {
  846. return E_FAIL;
  847. }
  848. CScopePaneItem* pItem = NULL;
  849. if( pScopeDataItem->lParam == 0L ) // cookie is NULL for Root Item
  850. {
  851. pItem = pThis->GetRootScopeItem();
  852. }
  853. else
  854. {
  855. pItem = (CScopePaneItem*)pScopeDataItem->lParam;
  856. }
  857. if( ! CHECKOBJPTR(pItem,RUNTIME_CLASS(CScopePaneItem),sizeof(CScopePaneItem)) )
  858. {
  859. return E_FAIL;
  860. }
  861. if( pScopeDataItem->mask & SDI_STR )
  862. {
  863. pScopeDataItem->displayname = (LPTSTR)(LPCTSTR)pItem->GetDisplayName();
  864. }
  865. if( pScopeDataItem->mask & SDI_IMAGE )
  866. {
  867. pScopeDataItem->nImage = pThis->AddIcon(pItem->GetIconId());
  868. }
  869. if( pScopeDataItem->mask & SDI_OPENIMAGE )
  870. {
  871. pScopeDataItem->nOpenImage = pThis->AddIcon(pItem->GetOpenIconId());
  872. }
  873. return S_OK;
  874. }
  875. HRESULT FAR EXPORT CScopePane::XComponentData::CompareObjects(
  876. /* [in] */ LPDATAOBJECT lpDataObjectA,
  877. /* [in] */ LPDATAOBJECT lpDataObjectB)
  878. {
  879. METHOD_PROLOGUE(CScopePane, ComponentData)
  880. TRACEX(_T("CScopePane::XComponentData::CompareObjects\n"));
  881. TRACEARGn(lpDataObjectA);
  882. TRACEARGn(lpDataObjectB);
  883. CSnapinDataObject* psmdo1 = CSnapinDataObject::GetSnapinDataObject(lpDataObjectA);
  884. if( psmdo1 == NULL )
  885. {
  886. return S_FALSE;
  887. }
  888. CSnapinDataObject* psmdo2 = CSnapinDataObject::GetSnapinDataObject(lpDataObjectB);
  889. if( psmdo2 == NULL )
  890. {
  891. return S_FALSE;
  892. }
  893. if( psmdo1->GetCookie() != psmdo2->GetCookie() )
  894. return S_FALSE;
  895. return S_OK;
  896. }
  897. // IComponentData Interface Part
  898. /////////////////////////////////////////////////////////////////////////////
  899. /////////////////////////////////////////////////////////////////////////////
  900. // IPersistStream Interface Part
  901. ULONG FAR EXPORT CScopePane::XPersistStream::AddRef()
  902. {
  903. METHOD_PROLOGUE(CScopePane, PersistStream)
  904. return pThis->ExternalAddRef();
  905. }
  906. ULONG FAR EXPORT CScopePane::XPersistStream::Release()
  907. {
  908. METHOD_PROLOGUE(CScopePane, PersistStream)
  909. return pThis->ExternalRelease();
  910. }
  911. HRESULT FAR EXPORT CScopePane::XPersistStream::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  912. {
  913. METHOD_PROLOGUE(CScopePane, PersistStream)
  914. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  915. }
  916. HRESULT FAR EXPORT CScopePane::XPersistStream::GetClassID(
  917. /* [out] */ CLSID __RPC_FAR *pClassID)
  918. {
  919. METHOD_PROLOGUE(CScopePane, PersistStream)
  920. TRACEX(_T("CScopePane::XPersistStream::GetClassID\n"));
  921. TRACEARGn(pClassID);
  922. return E_NOTIMPL;
  923. }
  924. HRESULT FAR EXPORT CScopePane::XPersistStream::IsDirty( void)
  925. {
  926. METHOD_PROLOGUE(CScopePane, PersistStream)
  927. TRACEX(_T("CScopePane::XPersistStream::IsDirty\n"));
  928. return E_NOTIMPL;
  929. }
  930. HRESULT FAR EXPORT CScopePane::XPersistStream::Load(
  931. /* [unique][in] */ IStream __RPC_FAR *pStm)
  932. {
  933. METHOD_PROLOGUE(CScopePane, PersistStream)
  934. TRACEX(_T("CScopePane::XPersistStream::Load\n"));
  935. TRACEARGn(pStm);
  936. COleStreamFile file;
  937. file.Attach(pStm);
  938. CArchive ar(&file,CArchive::load);
  939. bool bResult = pThis->OnLoad(ar);
  940. return bResult ? S_OK : E_FAIL;
  941. }
  942. HRESULT FAR EXPORT CScopePane::XPersistStream::Save(
  943. /* [unique][in] */ IStream __RPC_FAR *pStm,
  944. /* [in] */ BOOL fClearDirty)
  945. {
  946. METHOD_PROLOGUE(CScopePane, PersistStream)
  947. TRACEX(_T("CScopePane::XPersistStream::Save\n"));
  948. TRACEARGn(pStm);
  949. TRACEARGn(fClearDirty);
  950. COleStreamFile file;
  951. file.Attach(pStm);
  952. CArchive ar(&file,CArchive::store);
  953. bool bResult = pThis->OnSave(ar);
  954. return bResult ? S_OK : E_FAIL;
  955. }
  956. HRESULT FAR EXPORT CScopePane::XPersistStream::GetSizeMax(
  957. /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbSize)
  958. {
  959. METHOD_PROLOGUE(CScopePane, PersistStream)
  960. TRACEX(_T("CScopePane::XPersistStream::GetSizeMax\n"));
  961. TRACEARGn(pcbSize);
  962. return E_NOTIMPL;
  963. }
  964. // IPersistStream Interface Part
  965. /////////////////////////////////////////////////////////////////////////////
  966. /////////////////////////////////////////////////////////////////////////////
  967. // IExtendContextMenu Interface Part
  968. ULONG FAR EXPORT CScopePane::XExtendContextMenu::AddRef()
  969. {
  970. METHOD_PROLOGUE(CScopePane, ExtendContextMenu)
  971. return pThis->ExternalAddRef();
  972. }
  973. ULONG FAR EXPORT CScopePane::XExtendContextMenu::Release()
  974. {
  975. METHOD_PROLOGUE(CScopePane, ExtendContextMenu)
  976. return pThis->ExternalRelease();
  977. }
  978. HRESULT FAR EXPORT CScopePane::XExtendContextMenu::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  979. {
  980. METHOD_PROLOGUE(CScopePane, ExtendContextMenu)
  981. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  982. }
  983. HRESULT FAR EXPORT CScopePane::XExtendContextMenu::AddMenuItems(
  984. /* [in] */ LPDATAOBJECT piDataObject,
  985. /* [in] */ LPCONTEXTMENUCALLBACK piCallback,
  986. /* [out][in] */ long __RPC_FAR *pInsertionAllowed)
  987. {
  988. METHOD_PROLOGUE(CScopePane, ExtendContextMenu)
  989. TRACEX(_T("CScopePane::XExtendContextMenu::AddMenuItems\n"));
  990. TRACEARGn(piDataObject);
  991. TRACEARGn(piCallback);
  992. TRACEARGn(pInsertionAllowed);
  993. HRESULT hr = S_OK;
  994. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(piDataObject);
  995. if( ! CHECKOBJPTR(psdo, RUNTIME_CLASS(CSnapinDataObject), sizeof(CSnapinDataObject)) )
  996. {
  997. return E_FAIL;
  998. }
  999. DATA_OBJECT_TYPES type = psdo->GetItemType();
  1000. if( type == CCT_SCOPE )
  1001. {
  1002. CScopePaneItem* pItem = NULL;
  1003. if( ! psdo->GetItem(pItem) )
  1004. {
  1005. return E_FAIL;
  1006. }
  1007. ASSERT(pItem);
  1008. hr = pItem->OnAddMenuItems(piCallback,pInsertionAllowed);
  1009. if( ! CHECKHRESULT(hr) )
  1010. {
  1011. TRACE(_T("CScopePaneItem::OnAddMenuItems failed!\n"));
  1012. }
  1013. }
  1014. else if( type == CCT_RESULT )
  1015. {
  1016. CResultsPaneItem* pItem = NULL;
  1017. if( ! psdo->GetItem(pItem) )
  1018. {
  1019. return E_FAIL;
  1020. }
  1021. ASSERT(pItem);
  1022. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  1023. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  1024. {
  1025. return E_FAIL;
  1026. }
  1027. hr = pView->OnAddMenuItems(pItem,piCallback,pInsertionAllowed);
  1028. if( ! CHECKHRESULT(hr) )
  1029. {
  1030. TRACE(_T("CResultsPaneView::OnAddMenuItems failed!\n"));
  1031. }
  1032. }
  1033. return hr;
  1034. }
  1035. HRESULT FAR EXPORT CScopePane::XExtendContextMenu::Command(
  1036. /* [in] */ long lCommandID,
  1037. /* [in] */ LPDATAOBJECT piDataObject)
  1038. {
  1039. METHOD_PROLOGUE(CScopePane, ExtendContextMenu)
  1040. TRACEX(_T("CScopePane::XExtendContextMenu::Command\n"));
  1041. TRACEARGn(lCommandID);
  1042. TRACEARGn(piDataObject);
  1043. HRESULT hr = S_OK;
  1044. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(piDataObject);
  1045. if( ! CHECKOBJPTR(psdo, RUNTIME_CLASS(CSnapinDataObject), sizeof(CSnapinDataObject)) )
  1046. {
  1047. return E_FAIL;
  1048. }
  1049. DATA_OBJECT_TYPES type = psdo->GetItemType();
  1050. if( type == CCT_SCOPE )
  1051. {
  1052. CScopePaneItem* pItem = NULL;
  1053. if( ! psdo->GetItem(pItem) )
  1054. {
  1055. return E_FAIL;
  1056. }
  1057. ASSERT(pItem);
  1058. hr = pItem->OnCommand(lCommandID);
  1059. if( ! CHECKHRESULT(hr) )
  1060. {
  1061. TRACE(_T("CScopePaneItem::OnCommand failed!\n"));
  1062. }
  1063. }
  1064. return hr;
  1065. }
  1066. // IExtendContextMenu Interface Part
  1067. /////////////////////////////////////////////////////////////////////////////
  1068. /////////////////////////////////////////////////////////////////////////////
  1069. // IExtendPropertySheet2 Interface Part
  1070. ULONG FAR EXPORT CScopePane::XExtendPropertySheet2::AddRef()
  1071. {
  1072. METHOD_PROLOGUE(CScopePane, ExtendPropertySheet2)
  1073. return pThis->ExternalAddRef();
  1074. }
  1075. ULONG FAR EXPORT CScopePane::XExtendPropertySheet2::Release()
  1076. {
  1077. METHOD_PROLOGUE(CScopePane, ExtendPropertySheet2)
  1078. return pThis->ExternalRelease();
  1079. }
  1080. HRESULT FAR EXPORT CScopePane::XExtendPropertySheet2::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  1081. {
  1082. METHOD_PROLOGUE(CScopePane, ExtendPropertySheet2)
  1083. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  1084. }
  1085. HRESULT FAR EXPORT CScopePane::XExtendPropertySheet2::CreatePropertyPages(
  1086. /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
  1087. /* [in] */ LONG_PTR handle,
  1088. /* [in] */ LPDATAOBJECT lpIDataObject)
  1089. {
  1090. METHOD_PROLOGUE(CScopePane, ExtendPropertySheet2)
  1091. TRACEX(_T("CScopePane::XExtendPropertySheet2::CreatePropertyPages\n"));
  1092. TRACEARGn(lpProvider);
  1093. TRACEARGn(handle);
  1094. TRACEARGn(lpIDataObject);
  1095. HRESULT hr = S_FALSE;
  1096. CSnapinDataObject* psdo = CSnapinDataObject::GetSnapinDataObject(lpIDataObject);
  1097. if( ! CHECKOBJPTR(psdo, RUNTIME_CLASS(CSnapinDataObject), sizeof(CSnapinDataObject)) )
  1098. {
  1099. return E_FAIL;
  1100. }
  1101. DATA_OBJECT_TYPES type = psdo->GetItemType();
  1102. if( type == CCT_SCOPE )
  1103. {
  1104. CScopePaneItem* pItem = NULL;
  1105. if( ! psdo->GetItem(pItem) )
  1106. {
  1107. return E_FAIL;
  1108. }
  1109. ASSERT(pItem);
  1110. ASSERT_VALID(pItem);
  1111. hr = pItem->OnCreatePropertyPages(lpProvider,handle);
  1112. if( ! CHECKHRESULT(hr) )
  1113. {
  1114. TRACE(_T("CScopePaneItem::OnCreatePropertyPages failed!\n"));
  1115. }
  1116. }
  1117. else if( type == CCT_RESULT )
  1118. {
  1119. CResultsPaneItem* pItem = NULL;
  1120. if( ! psdo->GetItem(pItem) )
  1121. {
  1122. return E_FAIL;
  1123. }
  1124. ASSERT(pItem);
  1125. ASSERT_VALID(pItem);
  1126. CResultsPaneView* pView = pItem->GetOwnerResultsView();
  1127. if( ! CHECKOBJPTR(pView,RUNTIME_CLASS(CResultsPaneView),sizeof(CResultsPaneView)) )
  1128. {
  1129. return E_FAIL;
  1130. }
  1131. hr = pView->OnCreatePropertyPages(pItem,lpProvider,handle);
  1132. if( ! CHECKHRESULT(hr) )
  1133. {
  1134. TRACE(_T("CResultsPaneView::OnCreatePropertyPages failed!\n"));
  1135. }
  1136. }
  1137. return hr;
  1138. }
  1139. HRESULT FAR EXPORT CScopePane::XExtendPropertySheet2::QueryPagesFor(
  1140. /* [in] */ LPDATAOBJECT lpDataObject)
  1141. {
  1142. METHOD_PROLOGUE(CScopePane, ExtendPropertySheet2)
  1143. TRACEX(_T("CScopePane::XExtendPropertySheet2::QueryPagesFor\n"));
  1144. TRACEARGn(lpDataObject);
  1145. HRESULT hr = S_OK;
  1146. return hr;
  1147. }
  1148. HRESULT FAR EXPORT CScopePane::XExtendPropertySheet2::GetWatermarks(
  1149. /* [in] */ LPDATAOBJECT lpIDataObject,
  1150. /* [out] */ HBITMAP __RPC_FAR *lphWatermark,
  1151. /* [out] */ HBITMAP __RPC_FAR *lphHeader,
  1152. /* [out] */ HPALETTE __RPC_FAR *lphPalette,
  1153. /* [out] */ BOOL __RPC_FAR *bStretch)
  1154. {
  1155. METHOD_PROLOGUE(CScopePane, ExtendPropertySheet2)
  1156. TRACEX(_T("CScopePane::XExtendPropertySheet2::GetWatermarks\n"));
  1157. TRACEARGn(lpIDataObject);
  1158. TRACEARGn(lphWatermark);
  1159. TRACEARGn(lphHeader);
  1160. TRACEARGn(lphPalette);
  1161. TRACEARGn(bStretch);
  1162. return S_OK;
  1163. }
  1164. // IExtendPropertySheet2 Interface Part
  1165. /////////////////////////////////////////////////////////////////////////////
  1166. /////////////////////////////////////////////////////////////////////////////
  1167. // ISnapinHelp Interface Part
  1168. ULONG FAR EXPORT CScopePane::XSnapinHelp::AddRef()
  1169. {
  1170. METHOD_PROLOGUE(CScopePane, SnapinHelp)
  1171. return pThis->ExternalAddRef();
  1172. }
  1173. ULONG FAR EXPORT CScopePane::XSnapinHelp::Release()
  1174. {
  1175. METHOD_PROLOGUE(CScopePane, SnapinHelp)
  1176. return pThis->ExternalRelease();
  1177. }
  1178. HRESULT FAR EXPORT CScopePane::XSnapinHelp::QueryInterface(REFIID iid, void FAR* FAR* ppvObj)
  1179. {
  1180. METHOD_PROLOGUE(CScopePane, SnapinHelp)
  1181. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  1182. }
  1183. HRESULT FAR EXPORT CScopePane::XSnapinHelp::GetHelpTopic(
  1184. /* [out] */ LPOLESTR __RPC_FAR *lpCompiledHelpFile)
  1185. {
  1186. METHOD_PROLOGUE(CScopePane, SnapinHelp)
  1187. TRACEX(_T("CScopePane::XSnapinHelp::GetHelpTopic\n"));
  1188. TRACEARGn(lpCompiledHelpFile);
  1189. CString sHTMLHelpFilePath = AfxGetApp()->m_pszHelpFilePath;
  1190. *lpCompiledHelpFile = reinterpret_cast<LPOLESTR>(CoTaskMemAlloc((sHTMLHelpFilePath.GetLength() + 1)* sizeof(wchar_t)));
  1191. if (*lpCompiledHelpFile == NULL)
  1192. return E_OUTOFMEMORY;
  1193. _tcscpy(*lpCompiledHelpFile, (LPCTSTR)sHTMLHelpFilePath);
  1194. return S_OK;
  1195. }
  1196. // ISnapinHelp Interface Part
  1197. /////////////////////////////////////////////////////////////////////////////
  1198. /////////////////////////////////////////////////////////////////////////////
  1199. // CScopePane message handlers