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.

206 lines
7.0 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1999
  5. //
  6. // File: ocxcaching.h
  7. //
  8. // Contents: Classes that implement OCX caching snapin using the framework.
  9. //
  10. //--------------------------------------------------------------------
  11. #ifndef _OCXCACHING_H_
  12. #define _OCXCACHING_H_
  13. // Forward declarations.
  14. class COCXContainer;
  15. //+-------------------------------------------------------------------
  16. //
  17. // Class: COCXCachingSnapinRootItem
  18. //
  19. // Purpose: Implements the root item for a standalone snapin.
  20. //
  21. //--------------------------------------------------------------------
  22. class COCXCachingSnapinRootItem : public CBaseSnapinItem
  23. {
  24. typedef CBaseSnapinItem super;
  25. // Used by CBaseSnapinItem::ScCreateItem, connect this item with its children.
  26. typedef CComObject<CSnapinItem<COCXCachingSnapinRootItem> > t_item;
  27. typedef CComObject<CSnapinItem<COCXContainer> > t_itemChild; // Who is my child?
  28. public:
  29. COCXCachingSnapinRootItem( void ) {} // Raw constructor - use only for static item.
  30. virtual ~COCXCachingSnapinRootItem( void ) {}
  31. BEGIN_COM_MAP(COCXCachingSnapinRootItem)
  32. COM_INTERFACE_ENTRY(IDataObject) // Cant have empty map so add IDataObject
  33. END_COM_MAP()
  34. protected:
  35. // Item tree related information
  36. // node type related information
  37. virtual const CNodeType* Pnodetype( void ) { return &nodetypeSampleRoot;}
  38. // the display name of the item
  39. virtual const tstring* PstrDisplayName( void ) { return &m_strDisplayName;}
  40. // Get ListView data (GetDisplayInfo calls this).
  41. virtual SC ScGetField(DAT dat, tstring& strField);
  42. // Image list information
  43. virtual LONG Iconid() { return m_uIconIndex; }
  44. virtual LONG OpenIconid() { return m_uIconIndex; }
  45. virtual BOOL FIsContainer( void ) { return TRUE; }
  46. // Context menu support
  47. virtual SnapinMenuItem *Pmenuitem(void);
  48. virtual INT CMenuItem(void);
  49. virtual SC ScCommand(long nCommandID, CComponent *pComponent = NULL);
  50. virtual DWORD DwFlagsMenuChecked(void) { return TRUE;}
  51. public:
  52. virtual SC ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex = NULL, INT ccolinfoex = 0, BOOL fIsRoot = FALSE);
  53. public:
  54. // Creates children for the node
  55. virtual SC ScCreateChildren( void );
  56. protected:
  57. tstring m_strDisplayName;
  58. UINT m_uIconIndex;
  59. // For context menus
  60. static SnapinMenuItem s_rgmenuitem[];
  61. static INT s_cmenuitem;
  62. };
  63. //+-------------------------------------------------------------------
  64. //
  65. // Class: COCXContainer
  66. //
  67. // Purpose: Implements a scope pane item.
  68. //
  69. //--------------------------------------------------------------------
  70. class COCXContainer : public CBaseSnapinItem
  71. {
  72. typedef CBaseSnapinItem super;
  73. // Used by CBaseSnapinItem::ScCreateItem, connect this item with its children.
  74. typedef CComObject<CSnapinItem<COCXContainer> > t_item;
  75. // If we cache OCX's then it should be cached per IComponent. But this CBaseSnapinItem based
  76. // container is per snapin (not per IComponent) so we use a map to store the per IComponent OCX.
  77. typedef std::map<IConsole*, IUnknownPtr> CachedOCXs;
  78. public:
  79. COCXContainer( void ) {}
  80. virtual ~COCXContainer( void ) {}
  81. BEGIN_COM_MAP(COCXContainer)
  82. COM_INTERFACE_ENTRY(IDataObject) // Cant have empty map so add IDataObject
  83. END_COM_MAP()
  84. protected:
  85. // Item tree related information
  86. // node type related information
  87. const CNodeType *Pnodetype( void ) { return &nodetypeSampleLVContainer;}
  88. // the display name of the item
  89. virtual const tstring* PstrDisplayName( void ) { return &m_strDisplayName;}
  90. // Get ListView data (GetDisplayInfo calls this).
  91. virtual SC ScGetField(DAT dat, tstring& strField);
  92. // Image list information
  93. virtual LONG Iconid() { return m_uIconIndex; }
  94. virtual LONG OpenIconid() { return m_uIconIndex; }
  95. // This item attributes.
  96. virtual BOOL FIsContainer( void ) { return TRUE; }
  97. virtual BOOL FUsesResultList() { return FALSE;}
  98. virtual BOOL FResultPaneIsOCX() { return TRUE; }
  99. virtual SC ScGetOCXCLSID(tstring& strclsidOCX) { strclsidOCX = m_strOCX; return S_OK;}
  100. virtual BOOL FAllowMultiSelectionForChildren() { return FALSE;}
  101. virtual SC ScInitOCX(LPUNKNOWN pUnkOCX, IConsole* pConsole);
  102. virtual BOOL FCacheOCX();
  103. virtual IUnknown* GetCachedOCX(IConsole* pConsole);
  104. // There is no list-view so following methods are empty.
  105. virtual SC ScInitializeResultView(CComponent *pComponent) { return S_OK;}
  106. virtual SC ScOnAddImages(IImageList* ipResultImageList) { return S_OK;}
  107. public:
  108. virtual SC ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex = NULL, INT ccolinfoex = 0, BOOL fIsRoot = FALSE);
  109. public:
  110. // Creates children for the node
  111. virtual SC ScCreateChildren( void );
  112. static SC ScCreateLVContainer(CBaseSnapinItem *pitemParent, CBaseSnapinItem *pitemPrevious, COCXContainer ** ppitem, BOOL fNew);
  113. void SetOCXGUID(LPCTSTR szGUID) { m_strOCX = szGUID;}
  114. protected:
  115. // virtual SC ScGetVerbs(DWORD * pdwVerbs);
  116. protected:
  117. tstring m_strDisplayName;
  118. UINT m_uIconIndex;
  119. CachedOCXs m_mapOCXs;
  120. tstring m_strOCX;
  121. };
  122. //+-------------------------------------------------------------------
  123. //
  124. // Class: COCXCachingSnapin
  125. //
  126. // Purpose: Implements a snapin.
  127. //
  128. //--------------------------------------------------------------------
  129. class COCXCachingSnapin : public CBaseSnapin
  130. {
  131. // Specify the root node of the snapin.
  132. typedef CComObject<CSnapinItem<COCXCachingSnapinRootItem> > t_itemRoot;
  133. SNAPIN_DECLARE(COCXCachingSnapin);
  134. public:
  135. COCXCachingSnapin();
  136. virtual ~COCXCachingSnapin();
  137. // information about the snapin and root (ie initial) node
  138. virtual BOOL FStandalone() { return TRUE; }
  139. virtual BOOL FIsExtension() { return FALSE; }
  140. virtual BOOL FSupportsIComponent2() {return TRUE;}
  141. virtual LONG IdsDescription(void) {return IDS_OCXCachingRoot;}
  142. virtual LONG IdsName(void) {return IDS_OCXCachingSnapin;}
  143. const CSnapinInfo* Psnapininfo() { return &snapininfoOCXCaching; }
  144. bool FCacheOCX() { return m_bCacheOCX;}
  145. void SetCacheOCX(bool b) { m_bCacheOCX = b;}
  146. protected:
  147. // The column header info structures.
  148. static CColumnInfoEx s_colinfo[];
  149. static INT s_colwidths[];
  150. static INT s_ccolinfo;
  151. bool m_bCacheOCX;
  152. protected:
  153. virtual CColumnInfoEx* Pcolinfoex(INT icolinfo=0) { return s_colinfo + icolinfo; }
  154. virtual INT &ColumnWidth(INT icolwidth=0) { return s_colwidths[icolwidth]; }
  155. virtual INT Ccolinfoex() { return s_ccolinfo; }
  156. };
  157. #endif