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.

202 lines
7.0 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1999
  5. //
  6. // File: Component2snapin.hxx
  7. //
  8. // Contents: The snapin implements IComponentData2 & IComponent2 interfaces.
  9. // This file contains classes that implement framework methods on
  10. // CBaseSnapinItem to support these interfaces.
  11. //
  12. //--------------------------------------------------------------------
  13. #ifndef _COMPONENT2SNAPIN_HXX_
  14. #define _COMPONENT2SNAPIN_HXX_
  15. // Forward declarations.
  16. class CComponent2TestSnapinLVLeafItem;
  17. //+-------------------------------------------------------------------
  18. //
  19. // Class: CComponent2TestRootItem
  20. //
  21. // Purpose: Implements the root item for a standalone snapin.
  22. //
  23. //--------------------------------------------------------------------
  24. class CComponent2TestRootItem : public CBaseSnapinItem,
  25. public IDispatchImpl<ISnapinTasks, &IID_ISnapinTasks, &LIBID_TestSnapinsLib>
  26. {
  27. typedef CBaseSnapinItem super;
  28. // Used by CBaseSnapinItem::ScCreateItem, connect this item with its children.
  29. typedef CComObject<CSnapinItem<CComponent2TestRootItem> > t_item;
  30. typedef CComObject<CSnapinItem<CComponent2TestSnapinLVLeafItem> > t_itemChild;
  31. public:
  32. CComponent2TestRootItem( void ) {} // Raw constructor - use only for static item.
  33. virtual ~CComponent2TestRootItem( void ) {}
  34. BEGIN_COM_MAP(CComponent2TestRootItem)
  35. COM_INTERFACE_ENTRY(IDispatch)
  36. COM_INTERFACE_ENTRY(ISnapinTasks)
  37. END_COM_MAP()
  38. protected:
  39. // Item tree related information
  40. // node type related information
  41. virtual const CNodeType* Pnodetype( void ) { return &nodetypeComponent2TestRoot;}
  42. // the display name of the item
  43. virtual const tstring* PstrDisplayName( void ) { return &m_strDisplayName;}
  44. // Get ListView data (GetDisplayInfo calls this).
  45. virtual SC ScGetField(DAT dat, tstring& strField);
  46. // Image list information
  47. virtual LONG Iconid() { return m_uIconIndex; }
  48. virtual LONG OpenIconid() { return m_uIconIndex; }
  49. virtual BOOL FIsContainer( void ) { return TRUE; }
  50. public: // ISnapinTasks
  51. STDMETHOD(StringFromScriptToSnapin)(/*[in]*/ BSTR bstrMessage);
  52. STDMETHOD(StringFromSnapinToScript)(/*[out]*/ BSTR *pbstrMessage);
  53. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
  54. STDMETHOD(put_Name)(/*[in]*/ BSTR newVal);
  55. public:
  56. virtual SC ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex = NULL, INT ccolinfoex = 0, BOOL fIsRoot = FALSE);
  57. virtual SC ScQueryDispatch(long cookie, DATA_OBJECT_TYPES type, LPDISPATCH *ppDispatch);
  58. public:
  59. // Creates children for the node
  60. virtual SC ScCreateChildren( void );
  61. protected:
  62. tstring m_strDisplayName;
  63. UINT m_uIconIndex;
  64. };
  65. //+-------------------------------------------------------------------
  66. //
  67. // Class: CComponent2TestSnapinLVLeafItem
  68. //
  69. // Purpose: Implements a result pane item.
  70. //
  71. //--------------------------------------------------------------------
  72. class CComponent2TestSnapinLVLeafItem : public CBaseSnapinItem,
  73. public IDispatchImpl<ISnapinTasks, &IID_ISnapinTasks, &LIBID_TestSnapinsLib>
  74. {
  75. typedef CBaseSnapinItem super;
  76. // Used by CBaseSnapinItem::ScCreateItem, connect this item with its children.
  77. // This is a leaf item so this item acts as its child.
  78. typedef CComObject<CSnapinItem<CComponent2TestSnapinLVLeafItem> > t_item;
  79. typedef CComObject<CSnapinItem<CComponent2TestSnapinLVLeafItem> > t_itemChild;
  80. public:
  81. CComponent2TestSnapinLVLeafItem( void ) {}
  82. virtual ~CComponent2TestSnapinLVLeafItem( void ) {}
  83. BEGIN_COM_MAP(CComponent2TestSnapinLVLeafItem)
  84. COM_INTERFACE_ENTRY(IDispatch)
  85. COM_INTERFACE_ENTRY(ISnapinTasks)
  86. END_COM_MAP()
  87. protected:
  88. // Item tree related information
  89. // node type related information
  90. virtual const CNodeType *Pnodetype( void ) {return &nodetypeComponent2TestLVLeafItem;}
  91. // the display name of the item
  92. virtual const tstring* PstrDisplayName( void ) { return &m_strDisplayName; }
  93. // Get ListView data (GetDisplayInfo calls this).
  94. virtual SC ScGetField(DAT dat, tstring& strField);
  95. // Image list information
  96. virtual LONG Iconid() { return m_uIconIndex; }
  97. virtual BOOL FIsContainer( void ) { return FALSE; }
  98. // Context menu support
  99. virtual SnapinMenuItem *Pmenuitem(void);
  100. virtual INT CMenuItem(void);
  101. virtual SC ScCommand(long nCommandID, CComponent *pComponent = NULL);
  102. public: // ISnapinTasks
  103. STDMETHOD(StringFromScriptToSnapin)(/*[in]*/ BSTR bstrMessage);
  104. STDMETHOD(StringFromSnapinToScript)(/*[out]*/ BSTR *pbstrMessage);
  105. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
  106. STDMETHOD(put_Name)(/*[in]*/ BSTR newVal);
  107. public:
  108. virtual SC ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex = NULL, INT ccolinfoex = 0, BOOL fIsRoot = FALSE);
  109. virtual SC ScQueryDispatch(long cookie, DATA_OBJECT_TYPES type, LPDISPATCH *ppDispatch);
  110. public:
  111. static SC ScCreateLVLeafItem(CComponent2TestRootItem *pitemParent, t_itemChild * pitemPrevious, t_itemChild ** ppitem, BOOL fNew);
  112. protected:
  113. // virtual SC ScGetVerbs(DWORD * pdwVerbs);
  114. private:
  115. tstring m_strDisplayName;
  116. UINT m_uIconIndex;
  117. // For context menus
  118. static SnapinMenuItem s_rgmenuitemLVLeafItem[];
  119. static INT s_cmenuitemLVLeafItem;
  120. };
  121. //+-------------------------------------------------------------------
  122. //
  123. // Class: CComponent2Snapin
  124. //
  125. // Purpose: Implements a snapin.
  126. //
  127. //--------------------------------------------------------------------
  128. class CComponent2TestSnapin : public CBaseSnapin
  129. {
  130. // Specify the root node of the snapin.
  131. typedef CComObject<CSnapinItem<CComponent2TestRootItem> > t_itemRoot;
  132. SNAPIN_DECLARE(CComponent2TestSnapin);
  133. public:
  134. CComponent2TestSnapin();
  135. virtual ~CComponent2TestSnapin();
  136. // information about the snapin and root (ie initial) node
  137. virtual BOOL FStandalone() { return TRUE; }
  138. virtual BOOL FIsExtension() { return FALSE; }
  139. virtual BOOL FSupportsIComponent2() {return TRUE;}
  140. virtual LONG IdsDescription(void) {return IDS_Component2SNAPINDesc;}
  141. virtual LONG IdsName(void) {return IDS_Component2SNAPINName;}
  142. const CSnapinInfo* Psnapininfo() { return &snapininfoComponent2Test; }
  143. protected:
  144. // The column header info structures.
  145. static CColumnInfoEx s_colinfo[];
  146. static INT s_colwidths[];
  147. static INT s_ccolinfo;
  148. protected:
  149. virtual CColumnInfoEx* Pcolinfoex(INT icolinfo=0) { return s_colinfo + icolinfo; }
  150. virtual INT &ColumnWidth(INT icolwidth=0) { return s_colwidths[icolwidth]; }
  151. virtual INT Ccolinfoex() { return s_ccolinfo; }
  152. };
  153. #endif