Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2717 lines
73 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (c) 1997 Microsoft Corporation
  4. Module Name:
  5. snpnode.h
  6. Abstract:
  7. Header for the CSnapinNode class.
  8. This is our virtual base class for an MMC Snap-in node.
  9. As this is a template class and is all implemented inline,
  10. there is no SnapinNode.cpp for implementation.
  11. Author:
  12. Original: Michael A. Maguire
  13. Modifications: RaphiR
  14. Changes:
  15. Specific MSMQ support:
  16. Default images
  17. Default columns
  18. Support for Extension snapins
  19. Add a CComponentData pointer
  20. SetIcons method
  21. Move m_pParentNode to CSnapinItem
  22. zvib - Add RefreshSingleResultItem
  23. Jun 10 1999 adik Change bitmap mask to white.
  24. Jun 14 1999 roytal used UNREFERENCED_PARAMETER to fix build wrn
  25. Jun 24 1999 adik Handle MMCN_COLUMNS_CHANGED
  26. Jun 30 1999 adik More detailed DPF in CSnapinNode::Notify
  27. // //
  28. // Sep 22 1999 yossg welcome To Fax Server //
  29. // Oct 11 1999 yossg replace DPF with fax's DebugPrintfEx //
  30. --*/
  31. /////////////////////////////////////////////////////////////////////////////
  32. #if !defined(_SNAPIN_NODE_H_)
  33. #define _SNAPIN_NODE_H_
  34. #include <dlgutils.h>
  35. class CSnapin;
  36. class CSnapinItemEx
  37. {
  38. protected:
  39. CSnapinItemEx * m_pParentNodeEx;
  40. public:
  41. CSnapinItemEx(CSnapinItemEx * pParent)
  42. {
  43. m_pParentNodeEx = (CSnapinItemEx *)pParent;
  44. }
  45. CSnapinItemEx * GetRootNode()
  46. {
  47. if (m_pParentNodeEx)
  48. {
  49. return m_pParentNodeEx->GetRootNode();
  50. }
  51. else
  52. {
  53. return this;
  54. }
  55. }
  56. virtual void dummy(){}; // To support dynamic_cast
  57. CSnapinItemEx * GetParent()
  58. {
  59. return m_pParentNodeEx;
  60. }
  61. };
  62. template <class T, BOOL bIsExtension>
  63. class CSnapinNode : public CSnapInItemImpl< T, bIsExtension>,
  64. public CSnapinItemEx
  65. {
  66. protected:
  67. // Constructor/Destructor
  68. CSnapinNode(CSnapInItem *pParentNode, CSnapin *pComponentData);
  69. ~CSnapinNode();
  70. public:
  71. // For IDataObject handling.
  72. IDataObject* m_pDataObject;
  73. void InitDataClass(IDataObject* pDataObject, CSnapInItem* pDefault);
  74. //
  75. // Change the default icon id
  76. //
  77. void SetIcons(DWORD idStandard, DWORD idOpen);
  78. // Clipboard formats which IDataObjects on all MMC nodes must support.
  79. static const GUID* m_NODETYPE;
  80. static const TCHAR* m_SZNODETYPE;
  81. static const TCHAR* m_SZDISPLAY_NAME;
  82. static const CLSID* m_SNAPIN_CLASSID;
  83. // Pointer to parent node. This is passed in the call to our
  84. // constructor. Needed so that a node can access its parent.
  85. // For example, when we receive the MMCN_DELETE notification, we might tell
  86. // our parent node to remove us from its list of children.
  87. // The member is initialize in the constructor of CSnapinNode
  88. CSnapInItem * m_pParentNode;
  89. //
  90. // Pointer to the component data. Allow us to
  91. // access Snapin global data
  92. //
  93. CSnapin * m_pComponentData;
  94. HRESULT NodeMsgBox(int ids, UINT fuStyle = MB_OK | MB_ICONERROR, int *piRetval = NULL, BOOL StringFromCommonDll = FALSE);
  95. HRESULT RefreshSingleResultItem(CSnapInObjectRootBase *pRoot);
  96. HRESULT RefreshSingleResultItem(IConsole *spConsole);
  97. HRESULT RefreshSingleResultItem(IComponentData *pComponentData, IComponent * pComponent);
  98. public:
  99. // Standard MMC functionality -- override if you need to.
  100. STDMETHOD(CreatePropertyPages)(
  101. LPPROPERTYSHEETCALLBACK lpProvider
  102. , LONG_PTR handle
  103. , IUnknown* pUnk
  104. , DATA_OBJECT_TYPES type
  105. );
  106. STDMETHOD(QueryPagesFor)( DATA_OBJECT_TYPES type );
  107. void* GetDisplayName();
  108. STDMETHOD(GetScopePaneInfo)( SCOPEDATAITEM *pScopeDataItem );
  109. STDMETHOD(GetResultPaneInfo)( RESULTDATAITEM *pResultDataItem );
  110. virtual LPOLESTR GetResultPaneColInfo(int nCol);
  111. virtual HRESULT SetVerbs( IConsoleVerb * pConsoleVerb );
  112. // Notify method will call notification handlers below -- shouldn't need to override.
  113. STDMETHOD( Notify ) (
  114. MMC_NOTIFY_TYPE event
  115. , LPARAM arg
  116. , LPARAM param
  117. , IComponentData * pComponentData
  118. , IComponent * pComponent
  119. , DATA_OBJECT_TYPES type
  120. );
  121. // Notification handlers -- override when you want to intercept.
  122. virtual HRESULT OnActivate(
  123. LPARAM arg
  124. , LPARAM param
  125. , IComponentData * pComponentData
  126. , IComponent * pComponent
  127. , DATA_OBJECT_TYPES type
  128. );
  129. virtual HRESULT OnAddImages(
  130. LPARAM arg
  131. , LPARAM param
  132. , IComponentData * pComponentData
  133. , IComponent * pComponent
  134. , DATA_OBJECT_TYPES type
  135. );
  136. virtual HRESULT OnButtonClick(
  137. LPARAM arg
  138. , LPARAM param
  139. , IComponentData * pComponentData
  140. , IComponent * pComponent
  141. , DATA_OBJECT_TYPES type
  142. );
  143. virtual HRESULT OnClick(
  144. LPARAM arg
  145. , LPARAM param
  146. , IComponentData * pComponentData
  147. , IComponent * pComponent
  148. , DATA_OBJECT_TYPES type
  149. );
  150. virtual HRESULT OnContextHelp(
  151. LPARAM arg
  152. , LPARAM param
  153. , IComponentData * pComponentData
  154. , IComponent * pComponent
  155. , DATA_OBJECT_TYPES type
  156. );
  157. virtual HRESULT OnShowContextHelp(
  158. IDisplayHelp* pDisplayHelp
  159. , LPOLESTR helpFile);
  160. virtual HRESULT OnContextMenu(
  161. LPARAM arg
  162. , LPARAM param
  163. , IComponentData * pComponentData
  164. , IComponent * pComponent
  165. , DATA_OBJECT_TYPES type
  166. );
  167. virtual HRESULT OnDoubleClick(
  168. LPARAM arg
  169. , LPARAM param
  170. , IComponentData * pComponentData
  171. , IComponent * pComponent
  172. , DATA_OBJECT_TYPES type
  173. );
  174. virtual HRESULT OnDelete(
  175. LPARAM arg
  176. , LPARAM param
  177. , IComponentData * pComponentData
  178. , IComponent * pComponent
  179. , DATA_OBJECT_TYPES type
  180. , BOOL fSilent = FALSE
  181. );
  182. virtual HRESULT OnExpand(
  183. LPARAM arg
  184. , LPARAM param
  185. , IComponentData * pComponentData
  186. , IComponent * pComponent
  187. , DATA_OBJECT_TYPES type
  188. );
  189. virtual HRESULT OnHelp(
  190. LPARAM arg
  191. , LPARAM param
  192. , IComponentData * pComponentData
  193. , IComponent * pComponent
  194. , DATA_OBJECT_TYPES type
  195. );
  196. virtual HRESULT OnMenuButtonClick(
  197. LPARAM arg
  198. , LPARAM param
  199. , IComponentData * pComponentData
  200. , IComponent * pComponent
  201. , DATA_OBJECT_TYPES type
  202. );
  203. virtual HRESULT OnMinimized(
  204. LPARAM arg
  205. , LPARAM param
  206. , IComponentData * pComponentData
  207. , IComponent * pComponent
  208. , DATA_OBJECT_TYPES type
  209. );
  210. virtual HRESULT OnPaste(
  211. LPARAM arg
  212. , LPARAM param
  213. , IComponentData * pComponentData
  214. , IComponent * pComponent
  215. , DATA_OBJECT_TYPES type
  216. );
  217. virtual HRESULT OnPropertyChange(
  218. LPARAM arg
  219. , LPARAM param
  220. , IComponentData * pComponentData
  221. , IComponent * pComponent
  222. , DATA_OBJECT_TYPES type
  223. );
  224. virtual HRESULT OnQueryPaste(
  225. LPARAM arg
  226. , LPARAM param
  227. , IComponentData * pComponentData
  228. , IComponent * pComponent
  229. , DATA_OBJECT_TYPES type
  230. );
  231. virtual HRESULT OnRefresh(
  232. LPARAM arg
  233. , LPARAM param
  234. , IComponentData * pComponentData
  235. , IComponent * pComponent
  236. , DATA_OBJECT_TYPES type
  237. );
  238. virtual HRESULT OnRemoveChildren(
  239. LPARAM arg
  240. , LPARAM param
  241. , IComponentData * pComponentData
  242. , IComponent * pComponent
  243. , DATA_OBJECT_TYPES type
  244. );
  245. virtual HRESULT OnRename(
  246. LPARAM arg
  247. , LPARAM param
  248. , IComponentData * pComponentData
  249. , IComponent * pComponent
  250. , DATA_OBJECT_TYPES type
  251. );
  252. virtual HRESULT OnSelect(
  253. LPARAM arg
  254. , LPARAM param
  255. , IComponentData * pComponentData
  256. , IComponent * pComponent
  257. , DATA_OBJECT_TYPES type
  258. );
  259. virtual HRESULT OnShow(
  260. LPARAM arg
  261. , LPARAM param
  262. , IComponentData * pComponentData
  263. , IComponent * pComponent
  264. , DATA_OBJECT_TYPES type
  265. );
  266. virtual HRESULT OnViewChange(
  267. LPARAM arg
  268. , LPARAM param
  269. , IComponentData * pComponentData
  270. , IComponent * pComponent
  271. , DATA_OBJECT_TYPES type
  272. );
  273. virtual HRESULT OnColumnsChanged(
  274. LPARAM arg
  275. , LPARAM param
  276. , IComponentData * pComponentData
  277. , IComponent * pComponent
  278. , DATA_OBJECT_TYPES type
  279. );
  280. // Special notification handler -- saves off the currently selected node.
  281. HRESULT PreOnShow(
  282. LPARAM arg
  283. , LPARAM param
  284. , IComponentData * pComponentData
  285. , IComponent * pComponent
  286. , DATA_OBJECT_TYPES type
  287. );
  288. // Taskpad functionality.
  289. STDMETHOD(TaskNotify)(
  290. IDataObject * pDataObject
  291. , VARIANT * pvarg
  292. , VARIANT * pvparam
  293. );
  294. STDMETHOD(EnumTasks)(
  295. IDataObject * pDataObject
  296. , BSTR szTaskGroup
  297. , IEnumTASK** ppEnumTASK
  298. );
  299. };
  300. //////////////////////////////////////////////////////////////////////////////
  301. /*++
  302. CSnapinNode:SetIcons
  303. Specify the Open and Close icons of the snapin node
  304. Remarks:
  305. --*/
  306. //////////////////////////////////////////////////////////////////////////////
  307. template <class T, BOOL bIsExtension>
  308. void CSnapinNode<T, bIsExtension>::SetIcons(DWORD idStandard, DWORD idOpen)
  309. {
  310. m_scopeDataItem.nImage = idStandard;
  311. m_scopeDataItem.nOpenImage = idOpen;
  312. m_resultDataItem.nImage = idStandard;
  313. }
  314. //////////////////////////////////////////////////////////////////////////////
  315. /*++
  316. CSnapinNode:CreatePropertyPages
  317. Adds pages to a property sheet.
  318. HRESULT CreatePropertyPages(
  319. LPPROPERTYSHEETCALLBACK lpProvider,
  320. // Pointer to the callback interface
  321. long handle, // Handle for routing notification
  322. LPDATAOBJECT lpIDataObject // Pointer to the data object
  323. );
  324. Remarks:
  325. --*/
  326. //////////////////////////////////////////////////////////////////////////////
  327. template <class T, BOOL bIsExtension>
  328. STDMETHODIMP CSnapinNode<T, bIsExtension>::CreatePropertyPages(
  329. LPPROPERTYSHEETCALLBACK lpProvider
  330. , LONG_PTR handle
  331. , IUnknown* pUnk
  332. , DATA_OBJECT_TYPES type
  333. )
  334. {
  335. DEBUG_FUNCTION_NAME(TEXT("CreatePropertyPages"));
  336. UNREFERENCED_PARAMETER (lpProvider);
  337. UNREFERENCED_PARAMETER (handle);
  338. UNREFERENCED_PARAMETER (pUnk);
  339. UNREFERENCED_PARAMETER (type);
  340. DebugPrintEx(DEBUG_MSG,
  341. _T("CSnapinNode::CreatePropertyPages -- override in your derived class"));
  342. return E_NOTIMPL;
  343. }
  344. //////////////////////////////////////////////////////////////////////////////
  345. /*++
  346. CSnapinNode:QueryPagesFor
  347. Determines whether the object requires pages.
  348. HRESULT QueryPagesFor( DATA_OBJECT_TYPES type );
  349. Parameters
  350. void
  351. Return Value
  352. S_OK
  353. Properties exist for this cookie.
  354. E_UNEXPECTED
  355. An unexpected error occurred.
  356. E_INVALID
  357. The parameter is invalid.
  358. ISSUE: So what do we return if an item doesn't have property pages?
  359. S_FALSE is used in sburns' localsec code
  360. Remarks
  361. The console calls this method to determine whether the Properties menu
  362. item should be added to the context menu.
  363. Override this in your derived class, if your object supports menu
  364. --*/
  365. //////////////////////////////////////////////////////////////////////////////
  366. template <class T, BOOL bIsExtension>
  367. STDMETHODIMP CSnapinNode<T, bIsExtension>::QueryPagesFor( DATA_OBJECT_TYPES type )
  368. {
  369. DEBUG_FUNCTION_NAME(TEXT("QueryPagesFor"));
  370. UNREFERENCED_PARAMETER (type);
  371. DebugPrintEx(DEBUG_MSG,
  372. _T("CSnapinNode::QueryPagesFor -- override in your derived class if you have property pages"));
  373. // this method should be overriden and should return S_OK if you
  374. // have property pages for this node otherwise it should return S_FALSE.
  375. return S_FALSE;
  376. }
  377. //////////////////////////////////////////////////////////////////////////////
  378. /*++
  379. CSnapinNode:InitDataClass
  380. --*/
  381. //////////////////////////////////////////////////////////////////////////////
  382. template <class T, BOOL bIsExtension>
  383. void CSnapinNode<T, bIsExtension>::InitDataClass(IDataObject* pDataObject, CSnapInItem* pDefault)
  384. {
  385. UNREFERENCED_PARAMETER (pDefault);
  386. // The default code stores off the pointer to the Dataobject the class is wrapping
  387. // at the time.
  388. // Alternatively you could convert the dataobject to the internal format
  389. // it represents and store that information
  390. m_pDataObject = pDataObject;
  391. }
  392. //////////////////////////////////////////////////////////////////////////////
  393. /*++
  394. CSnapinNode:GetDisplayName
  395. ISSUE: what are the parameters to this function? Why not void?
  396. --*/
  397. //////////////////////////////////////////////////////////////////////////////
  398. template <class T, BOOL bIsExtension>
  399. void* CSnapinNode<T, bIsExtension>::GetDisplayName()
  400. {
  401. DEBUG_FUNCTION_NAME(
  402. _T("CSnapinNode::GetDisplayName"));
  403. // ISSUE: It looks as thought the m_SZDISPLAY_NAME is a totally
  404. // bogus variable -- we should think about eliminating it
  405. // Problematic -- const m_SZDISPLAY_NAME can't be localized
  406. // return (void*)m_SZDISPLAY_NAME;
  407. return (void*)m_bstrDisplayName;
  408. }
  409. // void* GetSnapInCLSID()
  410. // {
  411. // DPF(5, DBG_MMC,(_T("CSnapinNode::GetSnapInCLSID"));
  412. //
  413. // return (void*)m_SNAPIN_CLASSID;
  414. // }
  415. //////////////////////////////////////////////////////////////////////////////
  416. /*++
  417. CSnapinNode:GetScopePaneInfo
  418. --*/
  419. //////////////////////////////////////////////////////////////////////////////
  420. template <class T, BOOL bIsExtension>
  421. STDMETHODIMP CSnapinNode<T, bIsExtension>::GetScopePaneInfo( SCOPEDATAITEM *pScopeDataItem )
  422. {
  423. // DEBUG_FUNCTION_NAME( _T("CSnapinNode::GetScopePaneInfo"));
  424. if (pScopeDataItem->mask & SDI_STR)
  425. pScopeDataItem->displayname = m_bstrDisplayName;
  426. if (pScopeDataItem->mask & SDI_IMAGE)
  427. pScopeDataItem->nImage = m_scopeDataItem.nImage;
  428. if (pScopeDataItem->mask & SDI_OPENIMAGE)
  429. pScopeDataItem->nOpenImage = m_scopeDataItem.nOpenImage;
  430. if (pScopeDataItem->mask & SDI_PARAM)
  431. pScopeDataItem->lParam = m_scopeDataItem.lParam;
  432. if (pScopeDataItem->mask & SDI_STATE )
  433. pScopeDataItem->nState = m_scopeDataItem.nState;
  434. // TODO : Add code for SDI_CHILDREN
  435. return S_OK;
  436. }
  437. //////////////////////////////////////////////////////////////////////////////
  438. /*++
  439. CSnapinNode:GetResultPaneInfo
  440. --*/
  441. //////////////////////////////////////////////////////////////////////////////
  442. template <class T, BOOL bIsExtension>
  443. STDMETHODIMP CSnapinNode<T, bIsExtension>::GetResultPaneInfo( RESULTDATAITEM *pResultDataItem )
  444. {
  445. DEBUG_FUNCTION_NAME( _T("CSnapinNode::GetResultPaneInfo"));
  446. if (pResultDataItem->bScopeItem)
  447. {
  448. if (pResultDataItem->mask & RDI_STR)
  449. {
  450. pResultDataItem->str = GetResultPaneColInfo(pResultDataItem->nCol);
  451. }
  452. if (pResultDataItem->mask & RDI_IMAGE)
  453. {
  454. pResultDataItem->nImage = m_scopeDataItem.nImage;
  455. }
  456. if (pResultDataItem->mask & RDI_PARAM)
  457. {
  458. pResultDataItem->lParam = m_scopeDataItem.lParam;
  459. }
  460. return S_OK;
  461. }
  462. if (pResultDataItem->mask & RDI_STR)
  463. {
  464. pResultDataItem->str = GetResultPaneColInfo(pResultDataItem->nCol);
  465. }
  466. if (pResultDataItem->mask & RDI_IMAGE)
  467. {
  468. pResultDataItem->nImage = m_resultDataItem.nImage;
  469. }
  470. if (pResultDataItem->mask & RDI_PARAM)
  471. {
  472. pResultDataItem->lParam = m_resultDataItem.lParam;
  473. }
  474. if (pResultDataItem->mask & RDI_INDEX)
  475. {
  476. pResultDataItem->nIndex = m_resultDataItem.nIndex;
  477. }
  478. return S_OK;
  479. }
  480. //////////////////////////////////////////////////////////////////////////////
  481. /*++
  482. CSnapinNode::Notify
  483. This method is this node's response to the MMC calling Notify on
  484. IComponent or IComponentData.
  485. STDMETHOD( Notify ) (
  486. MMC_NOTIFY_TYPE event
  487. , LPARAM arg
  488. , LPARAM param
  489. , IComponentData * pComponentData
  490. , IComponent * pComponent
  491. , DATA_OBJECT_TYPES type
  492. )
  493. Parameters
  494. event
  495. [in] Identifies an action taken by a user. IComponent::Notify and
  496. IComponentData::Notify can receive the following notifications for a
  497. specific node:
  498. MMCN_ACTIVATE
  499. MMCN_ADD_IMAGES
  500. MMCN_BTN_CLICK
  501. MMCN_CLICK
  502. MMCN_CONTEXTMENU
  503. MMCN_DBLCLICK
  504. MMCN_DELETE
  505. MMCN_EXPAND
  506. MMCN_HELP
  507. MMCN_MENU_BTNCLICK
  508. MMCN_MINIMIZED
  509. MMCN_PROPERTY_CHANGE
  510. MMCN_REFRESH
  511. MMCN_REMOVE_CHILDREN
  512. MMCN_RENAME
  513. MMCN_SELECT
  514. MMCN_SHOW
  515. MMCN_VIEW_CHANGE
  516. MMCN_CONTEXTHELP
  517. See CSnapinNode::OnActivate, OnAddImages, OnButtonClick, etc. for
  518. a detailed explanation of each of these notify events
  519. arg
  520. Depends on the notification type.
  521. param
  522. Depends on the notification type.
  523. Return Values
  524. S_OK
  525. Depends on the notification type.
  526. E_UNEXPECTED
  527. An unexpected error occurred.
  528. Remarks
  529. Our IComponentData and IComponent implementations were passed a LPDATAOBJECT
  530. which corresponds to a node. This was converted to a pointer to
  531. a node object. Below is the Notify method on this node object, were
  532. the node object can deal with the Notify event itself.
  533. Our implementation of Notify is a large switch statement which delegates the
  534. task of dealing with virtual OnXxxxxx methods which can overridden in
  535. derived classes. As all events are dealt with this way here, you shouldn't
  536. need to implement a Notify method for any of your derived nodes.
  537. --*/
  538. //////////////////////////////////////////////////////////////////////////////
  539. template <class T, BOOL bIsExtension>
  540. STDMETHODIMP CSnapinNode<T, bIsExtension>:: Notify (
  541. MMC_NOTIFY_TYPE event
  542. , LPARAM arg
  543. , LPARAM param
  544. , IComponentData * pComponentData
  545. , IComponent * pComponent
  546. , DATA_OBJECT_TYPES type
  547. )
  548. {
  549. DEBUG_FUNCTION_NAME(TEXT("CSnapinNode<..>:: Notify"));
  550. UNREFERENCED_PARAMETER (param);
  551. UNREFERENCED_PARAMETER (type);
  552. DebugPrintEx(DEBUG_MSG,
  553. _T("CSnapinNode::Notify, event=0x%X, pComponentData=0x%X, pComponent=0x%X"),
  554. event, pComponentData, pComponent);
  555. HRESULT hr = S_FALSE;
  556. // this makes for faster code.
  557. T* pT = static_cast<T*> (this);
  558. switch( event )
  559. {
  560. case MMCN_ACTIVATE:
  561. hr = pT->OnActivate( arg, param, pComponentData, pComponent, type );
  562. break;
  563. case MMCN_ADD_IMAGES:
  564. hr = pT->OnAddImages( arg, param, pComponentData, pComponent, type );
  565. break;
  566. case MMCN_BTN_CLICK:
  567. hr = pT->OnButtonClick( arg, param, pComponentData, pComponent, type );
  568. break;
  569. case MMCN_CLICK:
  570. hr = pT->OnClick( arg, param, pComponentData, pComponent, type );
  571. break;
  572. case MMCN_CONTEXTHELP:
  573. hr = pT->OnContextHelp( arg, param, pComponentData, pComponent, type );
  574. break;
  575. case MMCN_CONTEXTMENU:
  576. hr = pT->OnContextMenu( arg, param, pComponentData, pComponent, type );
  577. break;
  578. case MMCN_CUTORMOVE:
  579. hr = pT->OnDelete( arg, param, pComponentData, pComponent, type, TRUE );
  580. break;
  581. case MMCN_DBLCLICK:
  582. hr = pT->OnDoubleClick( arg, param, pComponentData, pComponent, type );
  583. break;
  584. case MMCN_DELETE:
  585. hr = pT->OnDelete( arg, param, pComponentData, pComponent, type, FALSE );
  586. break;
  587. case MMCN_EXPAND:
  588. hr = pT->OnExpand( arg, param, pComponentData, pComponent, type );
  589. break;
  590. case MMCN_HELP:
  591. hr = pT->OnHelp( arg, param, pComponentData, pComponent, type );
  592. break;
  593. case MMCN_MENU_BTNCLICK:
  594. hr = pT->OnMenuButtonClick( arg, param, pComponentData, pComponent, type );
  595. break;
  596. case MMCN_MINIMIZED:
  597. hr = pT->OnMinimized( arg, param, pComponentData, pComponent, type );
  598. break;
  599. case MMCN_PASTE:
  600. hr = pT->OnPaste( arg, param, pComponentData, pComponent, type );
  601. break;
  602. case MMCN_PROPERTY_CHANGE:
  603. DebugPrintEx(DEBUG_MSG,_T("+++ MMCN_PROPERTY_CHANGE +++ \n"));
  604. hr = pT->OnPropertyChange( arg, param, pComponentData, pComponent, type );
  605. break;
  606. case MMCN_QUERY_PASTE:
  607. hr = pT->OnQueryPaste( arg, param, pComponentData, pComponent, type );
  608. break;
  609. case MMCN_REFRESH:
  610. hr = pT->OnRefresh( arg, param, pComponentData, pComponent, type );
  611. break;
  612. case MMCN_REMOVE_CHILDREN:
  613. hr = pT->OnRemoveChildren( arg, param, pComponentData, pComponent, type );
  614. break;
  615. case MMCN_RENAME:
  616. hr = pT->OnRename( arg, param, pComponentData, pComponent, type );
  617. break;
  618. case MMCN_SELECT:
  619. // For nodes with result-pane children
  620. hr = pT->OnSelect( arg, param, pComponentData, pComponent, type );
  621. break;
  622. case MMCN_SHOW:
  623. // For nodes with result-pane children
  624. // We call PreOnShow which will then call OnShow.
  625. // PreOnShow will save away the selected node in a member variable
  626. // of out CComponent class.
  627. //hr = pT->PreOnShow( arg, param, pComponentData, pComponent, type );
  628. hr = pT->OnShow( arg, param, pComponentData, pComponent, type );
  629. break;
  630. case MMCN_VIEW_CHANGE:
  631. hr = pT->OnViewChange( arg, param, pComponentData, pComponent, type );
  632. break;
  633. //
  634. // MMC 1.2, Win200 build 2059 support
  635. //
  636. case MMCN_COLUMNS_CHANGED:
  637. hr = pT->OnColumnsChanged(arg, param, pComponentData, pComponent, type);
  638. break;
  639. default:
  640. // Unhandled notify event.
  641. // MMC wants E_NOTIMPL if you can't do something or it will crash
  642. hr = E_NOTIMPL;
  643. break;
  644. }
  645. return hr;
  646. }
  647. //////////////////////////////////////////////////////////////////////////////
  648. /*++
  649. CSnapinNode:CSnapinNode
  650. Constructor
  651. This class is to be the virtual base class for all our nodes
  652. We never want people instantiating it so the constructor is protected
  653. --*/
  654. //////////////////////////////////////////////////////////////////////////////
  655. class CSnapinNode;
  656. template <class T, BOOL bIsExtension>
  657. CSnapinNode<T, bIsExtension>::CSnapinNode(CSnapInItem *pParentNode, CSnapin * pComponentData)
  658. : CSnapInItemImpl<T, bIsExtension>(),
  659. CSnapinItemEx(dynamic_cast<CSnapinItemEx *>(pParentNode))
  660. {
  661. DEBUG_FUNCTION_NAME(_T("CSnapinNode::CSnapinNode"));
  662. DebugPrintEx(DEBUG_MSG,
  663. _T("CSnapinNode::CSnapinNode, this=0x%X"), this);
  664. // Set the componet data
  665. m_pComponentData = pComponentData;
  666. // Set the parent node (in the base class CSnapinItem)
  667. m_pParentNode = pParentNode;
  668. // We set cookie for both scope and result pane data items,
  669. // as this class can be subclassed for either a scope-pane
  670. // or a result-pane-only node.
  671. // Sridhar moved this initialization code out of SnapInItemImpl
  672. memset(&m_scopeDataItem, 0, sizeof(SCOPEDATAITEM));
  673. m_scopeDataItem.mask = SDI_STR | SDI_IMAGE | SDI_OPENIMAGE | SDI_PARAM;
  674. m_scopeDataItem.displayname = MMC_CALLBACK;
  675. m_scopeDataItem.nImage = 0; // May need modification
  676. m_scopeDataItem.nOpenImage = 0; // May need modification
  677. // If this node is inserted in to the scope pane using
  678. // IConsoleNamespace->InsertItem, the value stored in lParam
  679. // will be what MMC later passes back as the cookie for this node.
  680. m_scopeDataItem.lParam = (LPARAM) this;
  681. // Sridhar moved this initialization code out of SnapInItemImpl
  682. memset(&m_resultDataItem, 0, sizeof(RESULTDATAITEM));
  683. m_resultDataItem.mask = RDI_STR | RDI_IMAGE | RDI_PARAM;
  684. m_resultDataItem.str = MMC_CALLBACK;
  685. m_resultDataItem.nImage = 0; // May need modification
  686. // If this node is inserted in to the result pane using
  687. // IResultData->InsertItem, the value stored in lParam will
  688. // be what MMC later passes back as the cookie for this node.
  689. m_resultDataItem.lParam = (LPARAM) this;
  690. }
  691. //////////////////////////////////////////////////////////////////////////////
  692. /*++
  693. CSnapinNode:~CSnapinNode
  694. Destructor
  695. --*/
  696. //////////////////////////////////////////////////////////////////////////////
  697. template <class T, BOOL bIsExtension>
  698. CSnapinNode<T, bIsExtension>::~CSnapinNode()
  699. {
  700. DEBUG_FUNCTION_NAME( _T("--- CSnapinNode::~CSnapinNode"));
  701. }
  702. //////////////////////////////////////////////////////////////////////////////
  703. /*++
  704. CSnapinNode:GetResultPaneColInfo
  705. By default, we return the display name in the first column, and blank ("")
  706. for other columns.
  707. Override in your derived class if you want more columns support
  708. --*/
  709. //////////////////////////////////////////////////////////////////////////////
  710. template <class T, BOOL bIsExtension>
  711. LPOLESTR CSnapinNode<T, bIsExtension>::GetResultPaneColInfo(int nCol)
  712. {
  713. DEBUG_FUNCTION_NAME( _T("CSnapinNode::GetResultPaneColInf"));
  714. if (nCol == 0)
  715. {
  716. return m_bstrDisplayName;
  717. }
  718. // Return the blank for other columns
  719. return OLESTR(" ");
  720. }
  721. /////////////////////////////////////////////////////////////////////////////
  722. /*++
  723. CSnapinNode::OnActivate
  724. virtual HRESULT OnActivate(
  725. , LPARAM arg
  726. , LPARAM param
  727. , IComponentData * pComponentData
  728. , IComponent * pComponent
  729. , DATA_OBJECT_TYPES type
  730. )
  731. In our implementation, this method gets called when the MMCN_ACTIVATE
  732. Notify message is sent for this node.
  733. MMC sends this message to the snap-in's IComponent::Notify method when a window is
  734. being activated or deactivated.
  735. Parameters
  736. arg
  737. TRUE if the window is activated; otherwise, it is FALSE.
  738. param
  739. Not used.
  740. Return Values
  741. Not used.
  742. --*/
  743. //////////////////////////////////////////////////////////////////////////////
  744. template <class T, BOOL bIsExtension>
  745. HRESULT CSnapinNode<T, bIsExtension>::OnActivate(
  746. LPARAM arg
  747. , LPARAM param
  748. , IComponentData * pComponentData
  749. , IComponent * pComponent
  750. , DATA_OBJECT_TYPES type
  751. )
  752. {
  753. UNREFERENCED_PARAMETER (arg);
  754. UNREFERENCED_PARAMETER (param);
  755. UNREFERENCED_PARAMETER (pComponentData);
  756. UNREFERENCED_PARAMETER (pComponent);
  757. UNREFERENCED_PARAMETER (type);
  758. DEBUG_FUNCTION_NAME( _T("CSnapinNode::OnActivate -- Override in your derived class"));
  759. return E_NOTIMPL;
  760. }
  761. /////////////////////////////////////////////////////////////////////////////
  762. /*++
  763. CSnapinNode::OnAddImages
  764. virtual HRESULT OnAddImages(
  765. , LPARAM arg
  766. , LPARAM param
  767. , IComponentData * pComponentData
  768. , IComponent * pComponent
  769. , DATA_OBJECT_TYPES type
  770. )
  771. We have chosen to handle this on a per-IComponent object basis, since it has
  772. very little to do (for us at least) with the particular IDataObject.
  773. See CComponent::OnAddImages for where we add images.
  774. This method loads the default ImageList we have
  775. Override this, if you want different imagelist
  776. By default, Loads specific images for this project
  777. --*/
  778. //////////////////////////////////////////////////////////////////////////////
  779. template <class T, BOOL bIsExtension>
  780. HRESULT CSnapinNode<T, bIsExtension>::OnAddImages(
  781. LPARAM arg
  782. , LPARAM param
  783. , IComponentData * pComponentData
  784. , IComponent * pComponent
  785. , DATA_OBJECT_TYPES type
  786. )
  787. {
  788. UNREFERENCED_PARAMETER (param);
  789. UNREFERENCED_PARAMETER (pComponentData);
  790. UNREFERENCED_PARAMETER (pComponent);
  791. UNREFERENCED_PARAMETER (type);
  792. DEBUG_FUNCTION_NAME(
  793. _T("CSnapinNode::OnAddImages"));
  794. HRESULT hr;
  795. IImageList* pImageList = (IImageList*) arg;
  796. hr = E_FAIL;
  797. // Load bitmaps associated with the scope pane
  798. // and add them to the image list
  799. // Loads the default bitmaps generated by the wizard
  800. // Change as required
  801. HBITMAP hBitmap16 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_TOOLBAR_16));
  802. if (hBitmap16 != NULL)
  803. {
  804. HBITMAP hBitmap32 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_TOOLBAR_32));
  805. if (hBitmap32 != NULL)
  806. {
  807. hr = pImageList->ImageListSetStrip((LONG_PTR*)hBitmap16,
  808. (LONG_PTR*)hBitmap32,
  809. 0,
  810. RGB(0, 128, 128));
  811. if (FAILED(hr))
  812. {
  813. DebugPrintEx(DEBUG_ERR,
  814. _T("IImageList::ImageListSetStrip failed"));
  815. }
  816. DeleteObject(hBitmap32);
  817. }
  818. DeleteObject(hBitmap16);
  819. }
  820. return(hr);
  821. }
  822. /////////////////////////////////////////////////////////////////////////////
  823. /*++
  824. CSnapinNode::OnButtonClick
  825. virtual HRESULT OnButtonClick(
  826. , LPARAM arg
  827. , LPARAM param
  828. , IComponentData * pComponentData
  829. , IComponent * pComponent
  830. , DATA_OBJECT_TYPES type
  831. )
  832. In our implementation, this method gets called when the MMCN_BTN_CLICK Notify message is
  833. sent for this node.
  834. MMC sends this message to the snap-in's IComponent, IComponentData,
  835. or IExtendControlbar implementation when a user clicks on one of the
  836. toolbar buttons.
  837. Parameters
  838. For IComponent::Notify or IComponentData::Notify:
  839. arg
  840. Must be zero.
  841. param
  842. CmdID of the button equal to a value of the MMC_CONSOLE_VERB enumeration.
  843. For IExtendControlBar::ControlbarNotify:
  844. arg
  845. Data object of the currently selected scope or result pane item.
  846. param
  847. [in] CmdID of the button equal to a value of the MMC_CONSOLE_VERB enumeration.
  848. Return Values
  849. Not used.
  850. --*/
  851. //////////////////////////////////////////////////////////////////////////////
  852. template <class T, BOOL bIsExtension>
  853. HRESULT CSnapinNode<T, bIsExtension>::OnButtonClick(
  854. LPARAM arg
  855. , LPARAM param
  856. , IComponentData * pComponentData
  857. , IComponent * pComponent
  858. , DATA_OBJECT_TYPES type
  859. )
  860. {
  861. DEBUG_FUNCTION_NAME(
  862. _T("CSnapinNode::OnButtonClick -- Override in your derived class"));
  863. UNREFERENCED_PARAMETER (arg);
  864. UNREFERENCED_PARAMETER (param);
  865. UNREFERENCED_PARAMETER (pComponentData);
  866. UNREFERENCED_PARAMETER (pComponent);
  867. UNREFERENCED_PARAMETER (type);
  868. return E_NOTIMPL;
  869. }
  870. /////////////////////////////////////////////////////////////////////////////
  871. /*++
  872. CSnapinNode::OnClick
  873. virtual HRESULT OnClick(
  874. , LPARAM arg
  875. , LPARAM param
  876. , IComponentData * pComponentData
  877. , IComponent * pComponent
  878. , DATA_OBJECT_TYPES type
  879. )
  880. In our implementation, this method gets called when the MMCN_CLICK Notify message is
  881. sent for this node.
  882. MMC sends this message to IComponent when a user clicks a mouse button
  883. on a list view item.
  884. Parameters
  885. arg
  886. Not used.
  887. param
  888. Not used.
  889. Return Values
  890. Not used.
  891. --*/
  892. //////////////////////////////////////////////////////////////////////////////
  893. template <class T, BOOL bIsExtension>
  894. HRESULT CSnapinNode<T, bIsExtension>::OnClick(
  895. LPARAM arg
  896. , LPARAM param
  897. , IComponentData * pComponentData
  898. , IComponent * pComponent
  899. , DATA_OBJECT_TYPES type
  900. )
  901. {
  902. UNREFERENCED_PARAMETER (arg);
  903. UNREFERENCED_PARAMETER (param);
  904. UNREFERENCED_PARAMETER (pComponentData);
  905. UNREFERENCED_PARAMETER (pComponent);
  906. UNREFERENCED_PARAMETER (type);
  907. DEBUG_FUNCTION_NAME(
  908. _T("CSnapinNode::OnClick -- Override in your derived class"));
  909. return E_NOTIMPL;
  910. }
  911. /////////////////////////////////////////////////////////////////////////////
  912. /*++
  913. CSnapinNode::OnContextHelp
  914. virtual HRESULT OnContextHelp(
  915. , LPARAM arg
  916. , LPARAM param
  917. , IComponentData * pComponentData
  918. , IComponent * pComponent
  919. , DATA_OBJECT_TYPES type
  920. )
  921. In our implementation, this method gets called when the MMCN_CONTEXTHELP Notify message is
  922. sent for this node.
  923. MMC sends this message when the user requests help about a selected item
  924. Parameters
  925. arg
  926. 0.
  927. param
  928. 0.
  929. Return Values
  930. Not used.
  931. --*/
  932. //////////////////////////////////////////////////////////////////////////////
  933. template <class T, BOOL bIsExtension>
  934. HRESULT CSnapinNode<T, bIsExtension>::OnContextHelp(
  935. LPARAM arg
  936. , LPARAM param
  937. , IComponentData * pComponentData
  938. , IComponent * pComponent
  939. , DATA_OBJECT_TYPES type
  940. )
  941. {
  942. UNREFERENCED_PARAMETER (arg);
  943. UNREFERENCED_PARAMETER (param);
  944. UNREFERENCED_PARAMETER (pComponentData);
  945. UNREFERENCED_PARAMETER (pComponent);
  946. UNREFERENCED_PARAMETER (type);
  947. HRESULT hr;
  948. PWSTR pszFilePath = ::GetHelpFile();
  949. DEBUG_FUNCTION_NAME(
  950. _T("CSnapinNode::OnContextHelp"));
  951. // But to get that, first we need IConsole
  952. CComPtr<IConsole> spConsole;
  953. if( pComponentData != NULL )
  954. {
  955. spConsole = ((CSnapin*)pComponentData)->m_spConsole;
  956. }
  957. else
  958. {
  959. // We should have a non-null pComponent
  960. spConsole = ((CSnapinComponent*)pComponent)->m_spConsole;
  961. }
  962. ATLASSERT( spConsole != NULL );
  963. CComPtr<IDisplayHelp> spDisplayHelp;
  964. hr = spConsole->QueryInterface(IID_IDisplayHelp, (void**)&spDisplayHelp);
  965. if(FAILED(hr))
  966. return hr;
  967. return OnShowContextHelp(spDisplayHelp, pszFilePath);
  968. }
  969. template <class T, BOOL bIsExtension>
  970. HRESULT CSnapinNode<T, bIsExtension>::OnShowContextHelp(
  971. IDisplayHelp* /*pDisplayHelp*/, LPOLESTR /*helpFile*/)
  972. {
  973. DEBUG_FUNCTION_NAME(
  974. _T("CSnapinNode::OnShowContextHelp -- Override in your derived class"));
  975. return E_NOTIMPL;
  976. }
  977. /////////////////////////////////////////////////////////////////////////////
  978. /*++
  979. CSnapinNode::OnContextMenu
  980. virtual HRESULT OnContextMenu(
  981. , LPARAM arg
  982. , LPARAM param
  983. , IComponentData * pComponentData
  984. , IComponent * pComponent
  985. , DATA_OBJECT_TYPES type
  986. )
  987. In our implementation, this method gets called when the MMCN_CONTEXTMENU Notify
  988. message is sent for this node.
  989. In the Fall 97 Platform SDK documentation, this event is listed as not used.
  990. Parameters
  991. arg
  992. TBD
  993. param
  994. TBD
  995. Return Values
  996. Not used.
  997. --*/
  998. //////////////////////////////////////////////////////////////////////////////
  999. template <class T, BOOL bIsExtension>
  1000. HRESULT CSnapinNode<T, bIsExtension>::OnContextMenu(
  1001. LPARAM arg
  1002. , LPARAM param
  1003. , IComponentData * pComponentData
  1004. , IComponent * pComponent
  1005. , DATA_OBJECT_TYPES type
  1006. )
  1007. {
  1008. UNREFERENCED_PARAMETER (arg);
  1009. UNREFERENCED_PARAMETER (param);
  1010. UNREFERENCED_PARAMETER (pComponentData);
  1011. UNREFERENCED_PARAMETER (pComponent);
  1012. UNREFERENCED_PARAMETER (type);
  1013. DEBUG_FUNCTION_NAME(
  1014. _T("CSnapinNode::OnContextMenu -- Override in your derived class"));
  1015. return E_NOTIMPL;
  1016. }
  1017. /////////////////////////////////////////////////////////////////////////////
  1018. /*++
  1019. CSnapinNode::OnDoubleClick
  1020. virtual HRESULT OnDoubleClick(
  1021. , LPARAM arg
  1022. , LPARAM param
  1023. , IComponentData * pComponentData
  1024. , IComponent * pComponent
  1025. , DATA_OBJECT_TYPES type
  1026. )
  1027. In our implementation, this method gets called when the MMCN_DBLCLICK Notify message is
  1028. sent for this node.
  1029. MMC sends this message to IComponent when a user double clicks a mouse
  1030. button on a list view item.
  1031. Parameters
  1032. arg
  1033. Not used.
  1034. param
  1035. Not used.
  1036. Return Values
  1037. Not used.
  1038. --*/
  1039. //////////////////////////////////////////////////////////////////////////////
  1040. template <class T, BOOL bIsExtension>
  1041. HRESULT CSnapinNode<T, bIsExtension>::OnDoubleClick(
  1042. LPARAM arg
  1043. , LPARAM param
  1044. , IComponentData * pComponentData
  1045. , IComponent * pComponent
  1046. , DATA_OBJECT_TYPES type
  1047. )
  1048. {
  1049. UNREFERENCED_PARAMETER (arg);
  1050. UNREFERENCED_PARAMETER (param);
  1051. UNREFERENCED_PARAMETER (pComponentData);
  1052. UNREFERENCED_PARAMETER (pComponent);
  1053. UNREFERENCED_PARAMETER (type);
  1054. DEBUG_FUNCTION_NAME(
  1055. _T("CSnapinNode::OnDoubleClick -- Override in your derived class if you don't want default verb action"));
  1056. // Through speaking with Eugene Baucom, I discovered that if you return S_FALSE
  1057. // here, the default verb action will occur when the user double clicks on a node.
  1058. // For the most part we have Properties as default verb, so a double click
  1059. // will cause property sheet on a node to pop up.
  1060. return S_FALSE;
  1061. }
  1062. /////////////////////////////////////////////////////////////////////////////
  1063. /*++
  1064. CSnapinNode::OnDelete
  1065. virtual HRESULT OnDelete(
  1066. , LPARAM arg
  1067. , LPARAM param
  1068. , IComponentData * pComponentData
  1069. , IComponent * pComponent
  1070. , DATA_OBJECT_TYPES type
  1071. )
  1072. In our implementation, this method gets called when the MMCN_DELETE Notify
  1073. message is sent for this node.
  1074. MMC sends this message to the snap-in's IComponent and IComponentData implementation to inform the snap-in that the object should be deleted.
  1075. Parameters
  1076. arg
  1077. Not used.
  1078. param
  1079. Not used.
  1080. Return Values
  1081. Not used.
  1082. Remarks
  1083. This message is generated when the user presses the delete key or uses
  1084. the mouse to click on the toolbar's delete button.
  1085. --*/
  1086. //////////////////////////////////////////////////////////////////////////////
  1087. template <class T, BOOL bIsExtension>
  1088. HRESULT CSnapinNode<T, bIsExtension>::OnDelete(
  1089. LPARAM arg
  1090. , LPARAM param
  1091. , IComponentData * pComponentData
  1092. , IComponent * pComponent
  1093. , DATA_OBJECT_TYPES type
  1094. , BOOL fSilent
  1095. )
  1096. {
  1097. UNREFERENCED_PARAMETER (arg);
  1098. UNREFERENCED_PARAMETER (param);
  1099. UNREFERENCED_PARAMETER (pComponentData);
  1100. UNREFERENCED_PARAMETER (pComponent);
  1101. UNREFERENCED_PARAMETER (type);
  1102. UNREFERENCED_PARAMETER (fSilent);
  1103. DEBUG_FUNCTION_NAME(
  1104. _T("CSnapinNode::OnDelete -- Override in your derived class"));
  1105. return E_NOTIMPL;
  1106. }
  1107. /////////////////////////////////////////////////////////////////////////////
  1108. /*++
  1109. CSnapinNode::OnExpand
  1110. virtual HRESULT OnExpand(
  1111. , LPARAM arg
  1112. , LPARAM param
  1113. , IComponentData * pComponentData
  1114. , IComponent * pComponent
  1115. , DATA_OBJECT_TYPES type
  1116. )
  1117. If your node will have scope-pane children,
  1118. this method should be overidden in your derived class.
  1119. In our implementation, this method gets called when the MMCN_EXPAND Notify message is
  1120. sent for this node.
  1121. MMC sends this message to the snap-in's IComponentData
  1122. implementation when a folder node needs to be expanded or contracted.
  1123. Parameters
  1124. arg
  1125. [in] If TRUE, the folder needs to be expanded. If FALSE, the folder needs to be contracted.
  1126. Param
  1127. [in] The HSCOPEITEM of the item that needs to be expanded.
  1128. Return Values
  1129. HRESULT
  1130. Remarks
  1131. On receipt of this notification the snap-in should enumerate the
  1132. children (sub-containers only) of the specified scope item, if any,
  1133. using IConsoleNameSpace methods. Subsequently, if a new item is added to
  1134. or deleted from this scope object through some external means, then
  1135. that item should also be added to or deleted from the console's
  1136. namespace using IConsoleNameSpace methods.
  1137. --*/
  1138. //////////////////////////////////////////////////////////////////////////////
  1139. template <class T, BOOL bIsExtension>
  1140. HRESULT CSnapinNode<T, bIsExtension>::OnExpand(
  1141. LPARAM arg
  1142. , LPARAM param
  1143. , IComponentData * pComponentData
  1144. , IComponent * pComponent
  1145. , DATA_OBJECT_TYPES type
  1146. )
  1147. {
  1148. UNREFERENCED_PARAMETER (arg);
  1149. UNREFERENCED_PARAMETER (param);
  1150. UNREFERENCED_PARAMETER (pComponentData);
  1151. UNREFERENCED_PARAMETER (pComponent);
  1152. UNREFERENCED_PARAMETER (type);
  1153. DEBUG_FUNCTION_NAME(
  1154. _T("CSnapinNode::OnExpand -- Override in your derived class"));
  1155. return E_NOTIMPL;
  1156. }
  1157. /////////////////////////////////////////////////////////////////////////////
  1158. /*++
  1159. CSnapinNode::OnHelp
  1160. virtual HRESULT OnHelp(
  1161. , LPARAM arg
  1162. , LPARAM param
  1163. , IComponentData * pComponentData
  1164. , IComponent * pComponent
  1165. , DATA_OBJECT_TYPES type
  1166. )
  1167. In our implementation, this method gets called when the MMCN_HELP Notify
  1168. message is sent for this node.
  1169. In the Fall 97 Platform SDK documentation, this event is listed as not used.
  1170. MMC sends this message when the user presses the F1 help key.
  1171. Parameters
  1172. arg
  1173. TBD
  1174. param
  1175. Pointer to a GUID. If NULL, the NodeType is used instead.
  1176. Return Values
  1177. Not used.
  1178. --*/
  1179. //////////////////////////////////////////////////////////////////////////////
  1180. template <class T, BOOL bIsExtension>
  1181. HRESULT CSnapinNode<T, bIsExtension>::OnHelp(
  1182. LPARAM arg
  1183. , LPARAM param
  1184. , IComponentData * pComponentData
  1185. , IComponent * pComponent
  1186. , DATA_OBJECT_TYPES type
  1187. )
  1188. {
  1189. UNREFERENCED_PARAMETER (arg);
  1190. UNREFERENCED_PARAMETER (param);
  1191. UNREFERENCED_PARAMETER (pComponentData);
  1192. UNREFERENCED_PARAMETER (pComponent);
  1193. UNREFERENCED_PARAMETER (type);
  1194. DEBUG_FUNCTION_NAME(
  1195. _T("CSnapinNode::OnHelp -- Override in your derived class"));
  1196. return E_NOTIMPL;
  1197. }
  1198. /////////////////////////////////////////////////////////////////////////////
  1199. /*++
  1200. CSnapinNode::OnMenuButtonClick
  1201. virtual HRESULT OnMenuButtonClick(
  1202. , LPARAM arg
  1203. , LPARAM param
  1204. , IComponentData * pComponentData
  1205. , IComponent * pComponent
  1206. , DATA_OBJECT_TYPES type
  1207. )
  1208. In our implementation, this method gets called when the MMCN_MENU_BTNCLICK Notify
  1209. message is sent for this node.
  1210. MMC sends this ify message is sent Sent to the snap-in's IExtendControlbar
  1211. interface when a user clicks on a menu button.
  1212. Parameters
  1213. arg
  1214. Data object of currently selected scope or result pane item.
  1215. param
  1216. [in] Pointer to a MENUBUTTONDATA structure.
  1217. Return Values
  1218. Not Used.
  1219. --*/
  1220. //////////////////////////////////////////////////////////////////////////////
  1221. template <class T, BOOL bIsExtension>
  1222. HRESULT CSnapinNode<T, bIsExtension>::OnMenuButtonClick(
  1223. LPARAM arg
  1224. , LPARAM param
  1225. , IComponentData * pComponentData
  1226. , IComponent * pComponent
  1227. , DATA_OBJECT_TYPES type
  1228. )
  1229. {
  1230. UNREFERENCED_PARAMETER (arg);
  1231. UNREFERENCED_PARAMETER (param);
  1232. UNREFERENCED_PARAMETER (pComponentData);
  1233. UNREFERENCED_PARAMETER (pComponent);
  1234. UNREFERENCED_PARAMETER (type);
  1235. DEBUG_FUNCTION_NAME(
  1236. _T("CSnapinNode::OnMenuButtonClick -- Override in your derived class"));
  1237. return E_NOTIMPL;
  1238. }
  1239. /////////////////////////////////////////////////////////////////////////////
  1240. /*++
  1241. CSnapinNode::OnMinimized
  1242. virtual HRESULT OnMinimized(
  1243. , LPARAM arg
  1244. , LPARAM param
  1245. , IComponentData * pComponentData
  1246. , IComponent * pComponent
  1247. , DATA_OBJECT_TYPES type
  1248. )
  1249. In our implementation, this method gets called when the MMCN_MINIMIZED Notify message is
  1250. sent for this node.
  1251. MMC sends this message to the snap-in's IComponent implementation when
  1252. a window is being minimized or maximized.
  1253. Parameters
  1254. arg
  1255. TRUE if the window has been minimized; otherwise, it is FALSE.
  1256. Param
  1257. Not used.
  1258. Return Values
  1259. Not Used
  1260. --*/
  1261. //////////////////////////////////////////////////////////////////////////////
  1262. template <class T, BOOL bIsExtension>
  1263. HRESULT CSnapinNode<T, bIsExtension>::OnMinimized(
  1264. LPARAM arg
  1265. , LPARAM param
  1266. , IComponentData * pComponentData
  1267. , IComponent * pComponent
  1268. , DATA_OBJECT_TYPES type
  1269. )
  1270. {
  1271. UNREFERENCED_PARAMETER (arg);
  1272. UNREFERENCED_PARAMETER (param);
  1273. UNREFERENCED_PARAMETER (pComponentData);
  1274. UNREFERENCED_PARAMETER (pComponent);
  1275. UNREFERENCED_PARAMETER (type);
  1276. DEBUG_FUNCTION_NAME(
  1277. _T("CSnapinNode::OnMinimized -- Override in your derived class"));
  1278. return E_NOTIMPL;
  1279. }
  1280. /////////////////////////////////////////////////////////////////////////////
  1281. /*++
  1282. CSnapinNode::OnPaste
  1283. virtual HRESULT OnPaste(
  1284. , LPARAM arg
  1285. , LPARAM param
  1286. , IComponentData * pComponentData
  1287. , IComponent * pComponent
  1288. , DATA_OBJECT_TYPES type
  1289. )
  1290. In our implementation, this method gets called when the MMCN_PASTE
  1291. Notify message is sent for this node.
  1292. Called to ask the snap-ins folder to paste the selected items.
  1293. Parameters
  1294. pDataobject
  1295. The data object in which to paste the selected items provided by the snap-in.
  1296. arg
  1297. The data object of the selected item(s) provided by the source snap-in that need to be pasted.
  1298. param
  1299. NULL for move (as opposed to cut).
  1300. For a single-item paste:
  1301. BOOL* pPasted = (BOOL*)param; Set this to TRUE here if the item was successfully pasted.
  1302. For a multiitem paste:
  1303. LPDATAOBJECT* ppDataObj = (LPDATAOBJECT*)param;
  1304. Use this to return a pointer to a data object consisting of the items successfully pasted. See MMCN_CUTORMOVE.
  1305. Return Values
  1306. Not used.
  1307. See Also
  1308. MMCN_CUTORMOVE
  1309. --*/
  1310. //////////////////////////////////////////////////////////////////////////////
  1311. template <class T, BOOL bIsExtension>
  1312. HRESULT CSnapinNode<T, bIsExtension>::OnPaste(
  1313. LPARAM arg
  1314. , LPARAM param
  1315. , IComponentData * pComponentData
  1316. , IComponent * pComponent
  1317. , DATA_OBJECT_TYPES type
  1318. )
  1319. {
  1320. UNREFERENCED_PARAMETER (arg);
  1321. UNREFERENCED_PARAMETER (param);
  1322. UNREFERENCED_PARAMETER (pComponentData);
  1323. UNREFERENCED_PARAMETER (pComponent);
  1324. UNREFERENCED_PARAMETER (type);
  1325. DEBUG_FUNCTION_NAME(
  1326. _T("CSnapinNode::OnPaste -- Override in your derived class"));
  1327. return E_NOTIMPL;
  1328. }
  1329. /////////////////////////////////////////////////////////////////////////////
  1330. /*++
  1331. CSnapinNode::OnPropertyChange
  1332. virtual HRESULT OnPropertyChange(
  1333. , LPARAM arg
  1334. , LPARAM param
  1335. , IComponentData * pComponentData
  1336. , IComponent * pComponent
  1337. , DATA_OBJECT_TYPES type
  1338. )
  1339. In our implementation, this method gets called when the MMCN_PROPERTY_CHANGE
  1340. Notify message is sent for this node.
  1341. When the snap-in uses the MMCPropertyChangeNotify function to notify it's
  1342. views about changes, MMC_PROPERTY_CHANGE is sent to the snap-in's
  1343. IComponentData and IComponent implementations.
  1344. Parameters
  1345. arg
  1346. [in] TRUE if the property change is for a scope pane item.
  1347. lParam
  1348. This is the param passed into MMCPropertyChangeNotify.
  1349. Return Values
  1350. Not used.
  1351. --*/
  1352. //////////////////////////////////////////////////////////////////////////////
  1353. template <class T, BOOL bIsExtension>
  1354. HRESULT CSnapinNode<T, bIsExtension>::OnPropertyChange(
  1355. LPARAM arg
  1356. , LPARAM param
  1357. , IComponentData * pComponentData
  1358. , IComponent * pComponent
  1359. , DATA_OBJECT_TYPES type
  1360. )
  1361. {
  1362. UNREFERENCED_PARAMETER (arg);
  1363. UNREFERENCED_PARAMETER (param);
  1364. UNREFERENCED_PARAMETER (pComponentData);
  1365. UNREFERENCED_PARAMETER (pComponent);
  1366. UNREFERENCED_PARAMETER (type);
  1367. DEBUG_FUNCTION_NAME(
  1368. _T("CSnapinNode::OnPropertyChange -- Override in your derived class"));
  1369. return E_NOTIMPL;
  1370. }
  1371. /////////////////////////////////////////////////////////////////////////////
  1372. /*++
  1373. CSnapinNode::OnQueryPaste
  1374. virtual HRESULT OnQueryPaste(
  1375. , LPARAM arg
  1376. , LPARAM param
  1377. , IComponentData * pComponentData
  1378. , IComponent * pComponent
  1379. , DATA_OBJECT_TYPES type
  1380. )
  1381. In our implementation, this method gets called when the MMCN_QUERY_PASTE
  1382. Notify message is sent for this node.
  1383. Sent to the snap-in before pasting into the snap-in's folder to determine if the
  1384. snap-in can accept the data.
  1385. Parameters
  1386. pdataobject
  1387. The dataobject of the selected item provided by the snap-in.
  1388. arg
  1389. The dataobject of the item(s) provided by the source snap-in that need to be pasted.
  1390. param
  1391. Not used.
  1392. Return Values
  1393. Not used.
  1394. See Also
  1395. MMCN_PASTE
  1396. --*/
  1397. //////////////////////////////////////////////////////////////////////////////
  1398. template <class T, BOOL bIsExtension>
  1399. HRESULT CSnapinNode<T, bIsExtension>::OnQueryPaste(
  1400. LPARAM arg
  1401. , LPARAM param
  1402. , IComponentData * pComponentData
  1403. , IComponent * pComponent
  1404. , DATA_OBJECT_TYPES type
  1405. )
  1406. {
  1407. UNREFERENCED_PARAMETER (arg);
  1408. UNREFERENCED_PARAMETER (param);
  1409. UNREFERENCED_PARAMETER (pComponentData);
  1410. UNREFERENCED_PARAMETER (pComponent);
  1411. UNREFERENCED_PARAMETER (type);
  1412. DEBUG_FUNCTION_NAME(
  1413. _T("CSnapinNode::OnQueryPaste -- Override in your derived class"));
  1414. return E_NOTIMPL;
  1415. }
  1416. /////////////////////////////////////////////////////////////////////////////
  1417. /*++
  1418. CSnapinNode::OnRefresh
  1419. virtual HRESULT OnRefresh(
  1420. , LPARAM arg
  1421. , LPARAM param
  1422. , IComponentData * pComponentData
  1423. , IComponent * pComponent
  1424. , DATA_OBJECT_TYPES type
  1425. )
  1426. In our implementation, this method gets called when the MMCN_REFRESH
  1427. Notify message is sent for this node.
  1428. In the Fall 97 Platform SDK documentation, this event is listed as TBD.
  1429. Parameters
  1430. Return Values
  1431. Not used.
  1432. --*/
  1433. //////////////////////////////////////////////////////////////////////////////
  1434. template <class T, BOOL bIsExtension>
  1435. HRESULT CSnapinNode<T, bIsExtension>::OnRefresh(
  1436. LPARAM arg
  1437. , LPARAM param
  1438. , IComponentData * pComponentData
  1439. , IComponent * pComponent
  1440. , DATA_OBJECT_TYPES type
  1441. )
  1442. {
  1443. UNREFERENCED_PARAMETER (arg);
  1444. UNREFERENCED_PARAMETER (param);
  1445. UNREFERENCED_PARAMETER (pComponentData);
  1446. UNREFERENCED_PARAMETER (pComponent);
  1447. UNREFERENCED_PARAMETER (type);
  1448. DEBUG_FUNCTION_NAME(
  1449. _T("CSnapinNode::OnRefresh -- Override in your derived class"));
  1450. return E_NOTIMPL;
  1451. }
  1452. /////////////////////////////////////////////////////////////////////////////
  1453. /*++
  1454. CSnapinNode::OnRemoveChildren
  1455. virtual HRESULT OnRemoveChildren(
  1456. , LPARAM arg
  1457. , LPARAM param
  1458. , IComponentData * pComponentData
  1459. , IComponent * pComponent
  1460. , DATA_OBJECT_TYPES type
  1461. )
  1462. In our implementation, this method gets called when the MMCN_REMOVE_CHILDREN
  1463. Notify message is sent for this node.
  1464. MMC sends this message to the snap-in's IComponentData implementation to inform
  1465. the snap-in that it must delete all the cookies (the entire subtree) it has
  1466. added below the specified node.
  1467. Parameters
  1468. arg
  1469. Specifies the HSCOPEITEM of the node whose children need to be deleted.
  1470. param
  1471. Not used.
  1472. Return Values
  1473. Not used.
  1474. Remarks
  1475. Use IConsoleNameSpace methods GetChildItem and GetNextItem to traverse
  1476. the tree and determine the cookies to be deleted.
  1477. --*/
  1478. //////////////////////////////////////////////////////////////////////////////
  1479. template <class T, BOOL bIsExtension>
  1480. HRESULT CSnapinNode<T, bIsExtension>::OnRemoveChildren(
  1481. LPARAM arg
  1482. , LPARAM param
  1483. , IComponentData * pComponentData
  1484. , IComponent * pComponent
  1485. , DATA_OBJECT_TYPES type
  1486. )
  1487. {
  1488. UNREFERENCED_PARAMETER (arg);
  1489. UNREFERENCED_PARAMETER (param);
  1490. UNREFERENCED_PARAMETER (pComponentData);
  1491. UNREFERENCED_PARAMETER (pComponent);
  1492. UNREFERENCED_PARAMETER (type);
  1493. DEBUG_FUNCTION_NAME(
  1494. _T("CSnapinNode::OnRemoveChildren -- Override in your derived class"));
  1495. return E_NOTIMPL;
  1496. }
  1497. /////////////////////////////////////////////////////////////////////////////
  1498. /*++
  1499. CSnapinNode::OnRename
  1500. virtual HRESULT OnRename(
  1501. , LPARAM arg
  1502. , LPARAM param
  1503. , IComponentData * pComponentData
  1504. , IComponent * pComponent
  1505. , DATA_OBJECT_TYPES type
  1506. )
  1507. In our implementation, this method gets called when the MMCN_RENAME Notify
  1508. message is sent for this node.
  1509. ISSUE: I do not seem to be seeing the two-call behaviour documented below
  1510. MMC sends this message the first time to query for a rename and the
  1511. second time to do the rename.
  1512. Parameters
  1513. arg
  1514. Not used.
  1515. param
  1516. LPOLESTR for containing the new name.
  1517. Return Values
  1518. S_OK
  1519. Allows the rename.
  1520. S_FALSE
  1521. Disallows the rename.
  1522. --*/
  1523. //////////////////////////////////////////////////////////////////////////////
  1524. template <class T, BOOL bIsExtension>
  1525. HRESULT CSnapinNode<T, bIsExtension>::OnRename(
  1526. LPARAM arg
  1527. , LPARAM param
  1528. , IComponentData * pComponentData
  1529. , IComponent * pComponent
  1530. , DATA_OBJECT_TYPES type
  1531. )
  1532. {
  1533. UNREFERENCED_PARAMETER (arg);
  1534. UNREFERENCED_PARAMETER (param);
  1535. UNREFERENCED_PARAMETER (pComponentData);
  1536. UNREFERENCED_PARAMETER (pComponent);
  1537. UNREFERENCED_PARAMETER (type);
  1538. DEBUG_FUNCTION_NAME(
  1539. _T("CSnapinNode::OnRename -- Override in your derived class"));
  1540. return E_NOTIMPL;
  1541. }
  1542. /////////////////////////////////////////////////////////////////////////////
  1543. /*++
  1544. CSnapinNode::OnSelect
  1545. virtual HRESULT OnSelect(
  1546. , LPARAM arg
  1547. , LPARAM param
  1548. , IComponentData * pComponentData
  1549. , IComponent * pComponent
  1550. , DATA_OBJECT_TYPES type
  1551. )
  1552. You shouldn't need to override this method. The OnSelect method has common
  1553. behaviour for all nodes, only the verbs to be set are different. Rather
  1554. than overriding OnSelect in each node, simply override SetVerbs, which this
  1555. implementation of OnSelect calls.
  1556. In our implementation, this method gets called when the MMCN_SELECT Notify message is
  1557. sent through IComponent::Notify for this node.
  1558. Note: MMC also sends the MMCN_SELECT message through IExtendControlbar::ControlbarNotify
  1559. but we don't respond to that here -- See CSnapInItem::ControlbarNotify for that.
  1560. Parameters
  1561. For IComponent::Notify:
  1562. arg
  1563. BOOL bScope = (BOOL) LOWORD(arg);
  1564. BOOL bSelec = (BOOL) HIWORD(arg);
  1565. bScope
  1566. TRUE if an item in the scope pane is selected.
  1567. FALSE if an item in the result view pane is selected.
  1568. bSelect
  1569. TRUE if the item is selected.
  1570. FALSE if the item is deselected.
  1571. param
  1572. This parameter is ignored.
  1573. Return Values
  1574. Not used.
  1575. Remarks
  1576. When an IComponent::Notify method receives the MMCN_SELECT notification
  1577. it should update the standard verbs.
  1578. --*/
  1579. //////////////////////////////////////////////////////////////////////////////
  1580. template <class T, BOOL bIsExtension>
  1581. HRESULT CSnapinNode<T, bIsExtension>::OnSelect(
  1582. LPARAM arg
  1583. , LPARAM param
  1584. , IComponentData * pComponentData
  1585. , IComponent * pComponent
  1586. , DATA_OBJECT_TYPES type
  1587. )
  1588. {
  1589. DEBUG_FUNCTION_NAME( _T("CSnapinNode::OnSelect"));
  1590. UNREFERENCED_PARAMETER (param);
  1591. UNREFERENCED_PARAMETER (type);
  1592. _ASSERTE( pComponentData != NULL || pComponent != NULL );
  1593. HRESULT hr = S_FALSE;
  1594. CComPtr<IConsoleVerb> spConsoleVerb;
  1595. BOOL bSelected = (BOOL) HIWORD( arg );
  1596. if( bSelected )
  1597. {
  1598. // Need IConsoleVerb
  1599. // But to get that, first we need IConsole
  1600. CComPtr<IConsole> spConsole;
  1601. if( pComponentData != NULL )
  1602. {
  1603. spConsole = ((CSnapin*)pComponentData)->m_spConsole;
  1604. }
  1605. else
  1606. {
  1607. // We should have a non-null pComponent
  1608. spConsole = ((CSnapinComponent*)pComponent)->m_spConsole;
  1609. }
  1610. _ASSERTE( spConsole != NULL );
  1611. hr = spConsole->QueryConsoleVerb( &spConsoleVerb );
  1612. _ASSERT( SUCCEEDED( hr ) );
  1613. hr = SetVerbs( spConsoleVerb );
  1614. }
  1615. else
  1616. {
  1617. // Anything to do here? Don't think so -- see sburns localsec example.
  1618. hr = S_OK;
  1619. }
  1620. return hr;
  1621. }
  1622. /////////////////////////////////////////////////////////////////////////////
  1623. /*++
  1624. CSnapinNode::SetVerbs
  1625. virtual HRESULT SetVerbs( IConsoleVerb * pConsoleVerb )
  1626. Override this method in your derived class.
  1627. This method is called by our default implementation of OnSelect
  1628. when the verbs for this node need to be set.
  1629. Parameters
  1630. IConsoleVerb * pConsoleVerb
  1631. Return Values
  1632. HRESULT
  1633. Remarks
  1634. The OnSelect method has common behaviour for all nodes, only the verbs
  1635. to be set are different. Rather than duplicate code by implementing OnSelect
  1636. in each node, simply override this SetVerbs method
  1637. Every time an item is selected, the verb states for all the commands
  1638. are returned to disabled and visible. It is up to the snap-in writer
  1639. to use IConsoleVerb to update the verb state every time an item is selected.
  1640. --*/
  1641. //////////////////////////////////////////////////////////////////////////////
  1642. template <class T, BOOL bIsExtension>
  1643. HRESULT CSnapinNode<T, bIsExtension>::SetVerbs( IConsoleVerb * pConsoleVerb )
  1644. {
  1645. UNREFERENCED_PARAMETER (pConsoleVerb);
  1646. DEBUG_FUNCTION_NAME(
  1647. _T("CSnapinNode::SetVerbs -- Override in your derived class"));
  1648. HRESULT hr = S_OK;
  1649. // Override in your derived class and do something like:
  1650. /*
  1651. // We want the user to be able to choose properties on this node
  1652. hr = pConsoleVerb->SetVerbState( MMC_VERB_PROPERTIES, ENABLED, TRUE );
  1653. // We want the default verb to be Properties
  1654. hr = pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  1655. // We want the user to be able to rename this node
  1656. hr = pConsoleVerb->SetVerbState( MMC_VERB_RENAME, ENABLED, TRUE );
  1657. */
  1658. return hr;
  1659. }
  1660. /////////////////////////////////////////////////////////////////////////////
  1661. /*++
  1662. CSnapinNode::PreOnShow
  1663. virtual HRESULT PreOnShow(
  1664. , LPARAM arg
  1665. , LPARAM param
  1666. , IComponentData * pComponentData
  1667. , IComponent * pComponent
  1668. , DATA_OBJECT_TYPES type
  1669. )
  1670. We call this instead of OnShow, so that we can save away the selected node.
  1671. This method will then just call OnShow.
  1672. --*/
  1673. //////////////////////////////////////////////////////////////////////////////
  1674. template <class T, BOOL bIsExtension>
  1675. HRESULT CSnapinNode<T, bIsExtension>::PreOnShow(
  1676. LPARAM arg
  1677. , LPARAM param
  1678. , IComponentData * pComponentData
  1679. , IComponent * pComponent
  1680. , DATA_OBJECT_TYPES type
  1681. )
  1682. {
  1683. DEBUG_FUNCTION_NAME(
  1684. _T("CSnapinNode::PreOnShow -- Don't override in your derived class"));
  1685. if( NULL != pComponent )
  1686. {
  1687. CSnapinComponent * pMyComponent = static_cast<CSnapinComponent *>( pComponent );
  1688. if( arg )
  1689. {
  1690. // We are being selected.
  1691. // Save our 'this' pointer as the currently selected node for this result view.
  1692. pMyComponent->m_pSelectedNode = static_cast<CSnapInItem *>( this );
  1693. }
  1694. else
  1695. {
  1696. // We are being deselected.
  1697. // Check to make sure that our result view doesn't think
  1698. // this node is the currently selected one.
  1699. if( pMyComponent->m_pSelectedNode == static_cast<CSnapInItem *>( this ) )
  1700. {
  1701. // We don't want to be the selected node anymore.
  1702. pMyComponent->m_pSelectedNode = NULL;
  1703. }
  1704. }
  1705. }
  1706. return OnShow( arg, param, pComponentData, pComponent, type );
  1707. }
  1708. /////////////////////////////////////////////////////////////////////////////
  1709. /*++
  1710. CSnapinNode::OnShow
  1711. virtual HRESULT OnShow(
  1712. , LPARAM arg
  1713. , LPARAM param
  1714. , IComponentData * pComponentData
  1715. , IComponent * pComponent
  1716. , DATA_OBJECT_TYPES type
  1717. )
  1718. If your node will have result-pane children,
  1719. this method should be overidden in your derived class.
  1720. In our implementation, this method gets called when the MMCN_SHOW Notify message is
  1721. sent for this node.
  1722. MMC sends this message when a scope item is selected or deselected for the
  1723. first time.
  1724. Parameters
  1725. arg
  1726. TRUE (<>0 ) if selecting; True indicates that the snap-in should set
  1727. up the result pane and add the enumerated items.
  1728. FALSE (0) if deselecting. indicates that the snap-in is going out of
  1729. focus and that it should clean up all cookies the right hand side
  1730. (the result pane), because current result pane will be replaced by a new one.
  1731. param
  1732. The HSCOPEITEM of the selected or deselected item.
  1733. Return Values
  1734. Not used.
  1735. --*/
  1736. //////////////////////////////////////////////////////////////////////////////
  1737. template <class T, BOOL bIsExtension>
  1738. HRESULT CSnapinNode<T, bIsExtension>::OnShow(
  1739. LPARAM arg
  1740. , LPARAM param
  1741. , IComponentData * pComponentData
  1742. , IComponent * pComponent
  1743. , DATA_OBJECT_TYPES type
  1744. )
  1745. {
  1746. UNREFERENCED_PARAMETER (arg);
  1747. UNREFERENCED_PARAMETER (param);
  1748. UNREFERENCED_PARAMETER (pComponentData);
  1749. UNREFERENCED_PARAMETER (pComponent);
  1750. UNREFERENCED_PARAMETER (type);
  1751. DEBUG_FUNCTION_NAME(
  1752. _T("CSnapinNode::OnShow -- Override in your derived class"));
  1753. // Returning E_NOTIMPL seems to be a bad thing here.
  1754. // It caused all kinds of problems with toolbar buttons persisting to
  1755. // the wrong node, as well as verbs not getting set correctly for nodes.
  1756. // Basically, if you don't respond with S_OK to the MMCN_SHOW notification,
  1757. // you won't get sent the appropriate MMCN_SELECT notification.
  1758. // return E_NOTIMPL;
  1759. return S_OK;
  1760. }
  1761. /////////////////////////////////////////////////////////////////////////////
  1762. /*++
  1763. CSnapinNode::OnViewChange
  1764. virtual HRESULT OnViewChange(
  1765. , LPARAM arg
  1766. , LPARAM param
  1767. , IComponentData * pComponentData
  1768. , IComponent * pComponent
  1769. , DATA_OBJECT_TYPES type
  1770. )
  1771. In our implementation, this method gets called when the MMCN_VIEW_CHANGE Notify
  1772. message is sent for this node.
  1773. MMC sends this message to the snap-in's IComponent implementation so it
  1774. can update all views when a change occurs. This node data object passed
  1775. to IConsole::UpdateAllViews.
  1776. Parameters
  1777. arg
  1778. [in] The data parameter passed to IConsole::UpdateAllViews.
  1779. param
  1780. [in] The hint parameter passed to IConsole::UpdateAllViews.
  1781. Return Values
  1782. Not used.
  1783. Remarks
  1784. This notification is generated when the snap-in (IComponent or
  1785. IComponentData) calls IConsole::UpdateAllViews.
  1786. --*/
  1787. //////////////////////////////////////////////////////////////////////////////
  1788. template <class T, BOOL bIsExtension>
  1789. HRESULT CSnapinNode<T, bIsExtension>::OnViewChange(
  1790. LPARAM arg
  1791. , LPARAM param
  1792. , IComponentData * pComponentData
  1793. , IComponent * pComponent
  1794. , DATA_OBJECT_TYPES type
  1795. )
  1796. {
  1797. UNREFERENCED_PARAMETER (arg);
  1798. UNREFERENCED_PARAMETER (param);
  1799. UNREFERENCED_PARAMETER (pComponentData);
  1800. UNREFERENCED_PARAMETER (pComponent);
  1801. UNREFERENCED_PARAMETER (type);
  1802. DEBUG_FUNCTION_NAME(
  1803. _T("CSnapinNode::OnViewChange -- Override in your derived class"));
  1804. return E_NOTIMPL;
  1805. }
  1806. /////////////////////////////////////////////////////////////////////////////
  1807. /*++
  1808. CSnapinNode::OnColumnsChanged
  1809. virtual HRESULT OnColumnsChanged(
  1810. , LPARAM arg
  1811. , LPARAM param
  1812. , IComponentData * pComponentData
  1813. , IComponent * pComponent
  1814. , DATA_OBJECT_TYPES type
  1815. )
  1816. In our implementation, this method gets called when the MMCN_COLUMNS_CHANGED Notify
  1817. message is sent for this node.
  1818. MMC sends this message to the snap-in's IComponent implementation so it
  1819. can decide if it can accept the column changes.
  1820. If snapin refuses to accept column changes then it is upto the snapin to display a message box
  1821. explaining the user why it is unable to do so.
  1822. Parameters
  1823. arg
  1824. [in] The data parameter passed to IConsole::UpdateAllViews.
  1825. param
  1826. [in] The hint parameter passed to IConsole::UpdateAllViews.
  1827. Return Values
  1828. S_OK,
  1829. A node can override this by returning E_UNEXPECTED that
  1830. discard user changes. In such a case display a message box
  1831. explaining the user why it is unable to do so.
  1832. Remarks
  1833. This notification is generated when the snap-in (IComponent or
  1834. IComponentData) calls IConsole::UpdateAllViews.
  1835. --*/
  1836. //////////////////////////////////////////////////////////////////////////////
  1837. template <class T, BOOL bIsExtension>
  1838. HRESULT CSnapinNode<T, bIsExtension>::OnColumnsChanged(
  1839. LPARAM arg
  1840. , LPARAM param
  1841. , IComponentData * pComponentData
  1842. , IComponent * pComponent
  1843. , DATA_OBJECT_TYPES type
  1844. )
  1845. {
  1846. UNREFERENCED_PARAMETER (arg);
  1847. UNREFERENCED_PARAMETER (param);
  1848. UNREFERENCED_PARAMETER (pComponentData);
  1849. UNREFERENCED_PARAMETER (pComponent);
  1850. UNREFERENCED_PARAMETER (type);
  1851. return S_OK;
  1852. }
  1853. /////////////////////////////////////////////////////////////////////////////
  1854. /*++
  1855. CSnapinNode::TaskNotify
  1856. Called when MMC wants to notify us that the user clicked on a task
  1857. on a taskpad belonging to this node.
  1858. --*/
  1859. //////////////////////////////////////////////////////////////////////////////
  1860. template <class T, BOOL bIsExtension>
  1861. STDMETHODIMP CSnapinNode<T, bIsExtension>::TaskNotify(
  1862. IDataObject * pDataObject
  1863. , VARIANT * pvarg
  1864. , VARIANT * pvparam
  1865. )
  1866. {
  1867. UNREFERENCED_PARAMETER (pDataObject);
  1868. UNREFERENCED_PARAMETER (pvarg);
  1869. UNREFERENCED_PARAMETER (pvparam);
  1870. DEBUG_FUNCTION_NAME(
  1871. _T("CSnapInItemImpl::TaskNotify - not impleneted"));
  1872. return E_NOTIMPL;
  1873. }
  1874. /////////////////////////////////////////////////////////////////////////////
  1875. /*++
  1876. CSnapinNode::EnumTasks
  1877. Called when MMC wants us to enumerate the tasks on a taskpad
  1878. belonging to this node.
  1879. --*/
  1880. //////////////////////////////////////////////////////////////////////////////
  1881. template <class T, BOOL bIsExtension>
  1882. STDMETHODIMP CSnapinNode<T, bIsExtension>::EnumTasks(
  1883. IDataObject * pDataObject
  1884. , BSTR szTaskGroup
  1885. , IEnumTASK** ppEnumTASK
  1886. )
  1887. {
  1888. UNREFERENCED_PARAMETER (pDataObject);
  1889. UNREFERENCED_PARAMETER (szTaskGroup);
  1890. UNREFERENCED_PARAMETER (ppEnumTASK);
  1891. DEBUG_FUNCTION_NAME(
  1892. _T("CSnapInItemImpl::EnumTasks - not impleneted"));
  1893. return E_NOTIMPL;
  1894. }
  1895. #define COMET_MMC_COMMON_DLL L"nemmcutl.dll"
  1896. /////////////////////////////////////////////////////////////////////////////
  1897. /*++
  1898. CSnapinNode::NodeMsgBox
  1899. Calls IConsole::MessageBox
  1900. Parameters
  1901. ids
  1902. [in] string table (in rc) id of the text
  1903. fuStyle
  1904. [in] MB_* mask. See Win32 MessageBox
  1905. piRetval
  1906. [out] Message return value (see IConsole::MessageBox)
  1907. StringFromCommonDll
  1908. [in] if true the resource is taken from nemmcutil.dll (zvib)
  1909. Return Values
  1910. The same as IConsole::MessageBox
  1911. Remarks
  1912. --*/
  1913. //////////////////////////////////////////////////////////////////////////////
  1914. template <class T, BOOL bIsExtension> HRESULT
  1915. CSnapinNode<T, bIsExtension>::NodeMsgBox(int ids,
  1916. UINT fuStyle/*=MB_OK*/,
  1917. int *piRetval/*=NULL*/,
  1918. BOOL StringFromCommonDll
  1919. )
  1920. {
  1921. ATLASSERT(m_pComponentData);
  1922. ATLASSERT(m_pComponentData->m_spConsole);
  1923. if(IsRTLUILanguage())
  1924. {
  1925. fuStyle |= MB_RTLREADING | MB_RIGHT;
  1926. }
  1927. return ::ConsoleMsgBox(m_pComponentData->m_spConsole, ids, m_bstrDisplayName, fuStyle, piRetval,StringFromCommonDll);
  1928. }
  1929. template <class T, BOOL bIsExtension>
  1930. HRESULT
  1931. CSnapinNode<T, bIsExtension>::RefreshSingleResultItem(CSnapInObjectRootBase *pRoot)
  1932. {
  1933. HRESULT hr = S_OK;
  1934. CComPtr<IConsole> spConsole;
  1935. CSnapinComponent *pComponent;
  1936. //[yg] Dec 15 1999
  1937. //compiler err
  1938. // error C2683: dynamic_cast : 'CSnapInObjectRootBase' is not a polymorphic type"
  1939. //in code:
  1940. // pComponent = dynamic_cast<CSnapinComponent*>(pRoot);
  1941. //changed to:
  1942. pComponent =(CSnapinComponent*)(pRoot);
  1943. _ASSERTE(pComponent != NULL);
  1944. spConsole = pComponent->m_spConsole;
  1945. _ASSERTE(spConsole != NULL);
  1946. hr = RefreshSingleResultItem(spConsole);
  1947. return(hr);
  1948. }
  1949. template <class T, BOOL bIsExtension>
  1950. HRESULT
  1951. CSnapinNode<T, bIsExtension>::RefreshSingleResultItem(IComponentData *pComponentData, IComponent * pComponent)
  1952. {
  1953. HRESULT hr = S_OK;
  1954. CComPtr<IConsole> spConsole;
  1955. if ((pComponentData != NULL))
  1956. {
  1957. spConsole = ((CSnapin*)pComponentData)->m_spConsole;
  1958. }
  1959. else
  1960. {
  1961. // We should have a non-null pComponent
  1962. spConsole = ((CSnapinComponent*)pComponent)->m_spConsole;
  1963. }
  1964. _ASSERTE(spConsole != NULL);
  1965. hr = RefreshSingleResultItem(spConsole);
  1966. return(hr);
  1967. }
  1968. template <class T, BOOL bIsExtension>
  1969. HRESULT
  1970. CSnapinNode<T, bIsExtension>::RefreshSingleResultItem(IConsole *spConsole)
  1971. {
  1972. HRESULT hr = S_OK;
  1973. // Need IResultData
  1974. CComQIPtr<IResultData, &IID_IResultData> pResultData(spConsole);
  1975. ATLASSERT(pResultData != NULL);
  1976. // Update the item
  1977. hr = pResultData->SetItem(&m_resultDataItem);
  1978. if (SUCCEEDED(hr))
  1979. hr = pResultData->UpdateItem(m_resultDataItem.itemID);
  1980. return(hr);
  1981. }
  1982. #endif // _SNAPIN_NODE_H_