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.

198 lines
10 KiB

  1. /*
  2. * component.hxx
  3. *
  4. *
  5. * Copyright (c) 1998-1999 Microsoft Corporation
  6. *
  7. * PURPOSE: Defines the CComponent class.
  8. *
  9. *
  10. * OWNER: ptousig
  11. */
  12. #pragma once
  13. // -----------------------------------------------------------------------------
  14. // -----------------------------------------------------------------------------
  15. // -----------------------------------------------------------------------------
  16. // CComponent
  17. //
  18. // This is the "view" of a snapin. One of these is created for each window in a
  19. // console.
  20. //
  21. class CComponent : public IComponent2,
  22. public IExtendContextMenu,
  23. public IExtendPropertySheet,
  24. public IPersistStreamInit,
  25. public IResultOwnerData,
  26. public IResultDataCompareEx,
  27. public CComObjectRoot
  28. {
  29. BEGIN_COM_MAP(CComponent)
  30. COM_INTERFACE_ENTRY(IComponent)
  31. COM_INTERFACE_ENTRY(IExtendContextMenu)
  32. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  33. COM_INTERFACE_ENTRY(IPersistStreamInit)
  34. COM_INTERFACE_ENTRY(IResultOwnerData)
  35. COM_INTERFACE_ENTRY(IResultDataCompareEx)
  36. COM_INTERFACE_ENTRY_FUNC(IID_IComponent2, 0 /*dw*/, QueryIComponent2)
  37. END_COM_MAP()
  38. DECLARE_NOT_AGGREGATABLE(CComponent);
  39. public:
  40. CComponent(void);
  41. virtual ~CComponent(void);
  42. //
  43. // Accessors
  44. //
  45. inline CBaseSnapin * Psnapin(void) { return m_pComponentData->Psnapin();}
  46. inline const tstring& StrSnapinClassName(void) { return Psnapin()->Psnapininfo()->StrClassName();}
  47. inline IConsoleVerb * IpConsoleVerb(void) { return m_ipConsoleVerb;}
  48. inline IHeaderCtrl * IpHeaderCtrl(void) { return m_ipHeaderCtrl;}
  49. inline IColumnData * IpColumnData(void) { return m_ipColumnDataPtr;}
  50. inline IResultData * IpResultData(void) { return m_ipResultData;}
  51. inline IConsole * IpConsole(void) { return m_ipConsole;}
  52. inline IImageList * IpImageList(void) { return m_ipImageList;}
  53. inline IPropertySheetProvider * IpPropertySheetProvider(void) { return m_ipPropertySheetProvider;}
  54. inline CComponentData * PComponentData(void) { return m_pComponentData;}
  55. inline CBaseSnapinItem * PitemScopeSelected(void) { return m_pitemScopeSelected;}
  56. inline void SetItemScopeSelected(CBaseSnapinItem * pitem) { m_pitemScopeSelected = pitem;}
  57. BOOL FVirtualResultsPane(void);
  58. void SetComponentData(CComponentData *pComponentData);
  59. //
  60. // Shortcuts
  61. //
  62. CBaseSnapinItem * Pitem(LPDATAOBJECT lpDataObject = NULL, HSCOPEITEM hscopeitem = 0, long cookie = 0);
  63. inline IConsoleNameSpace * IpConsoleNameSpace(void) { return PComponentData()->IpConsoleNameSpace();}
  64. // This function determines whether or not IComponent2 is exposed
  65. static HRESULT WINAPI QueryIComponent2(void* pv, REFIID riid, LPVOID* ppv, DWORD dw);
  66. public:
  67. // "Sc" versions of IComponent interface
  68. virtual SC ScInitialize(LPCONSOLE lpConsole);
  69. virtual SC ScNotify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, long arg, long param);
  70. virtual SC ScDestroy(void);
  71. virtual SC ScGetResultViewType(long cookie, LPOLESTR *ppViewType, long *pViewOptions);
  72. virtual SC ScQueryDataObject(long cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  73. virtual SC ScGetDisplayInfo(LPRESULTDATAITEM pResultItem);
  74. // "Sc" versions of IComponent2 interface
  75. virtual SC ScQueryDispatch(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDISPATCH* ppDispatch);
  76. virtual SC ScGetResultViewType2(MMC_COOKIE cookie, PRESULT_VIEW_TYPE_INFO pResultViewType);
  77. virtual SC ScRestoreResultView(MMC_COOKIE cookie, RESULT_VIEW_TYPE_INFO* pResultViewType);
  78. // "Sc" version of IExtendContextMenu interface
  79. virtual SC ScCommand(long nCommandID, LPDATAOBJECT pDataObject);
  80. // "Sc" version of IExtendPropertySheet interface
  81. virtual SC ScCreatePropertyPages(LPPROPERTYSHEETCALLBACK ipPropertySheetCallback, long handle, LPDATAOBJECT pDataObject);
  82. virtual SC ScQueryPagesFor(LPDATAOBJECT lpDataObject);
  83. // "Sc" version of IPersistStreamInit interface
  84. virtual SC ScIsDirty(void);
  85. virtual SC ScLoad(IStream *pstream);
  86. virtual SC ScSave(IStream *pstream, BOOL fClearDirty);
  87. // "Sc" version of IResultOwnerData interface
  88. virtual SC ScCacheHint(INT nStartIndex, INT nEndIndex);
  89. virtual SC ScSortItems(INT nColumn, DWORD dwSortOptions, long lUserParam);
  90. virtual SC ScFindItem(LPRESULTFINDINFO pFindinfo, INT * pnFoundIndex);
  91. // Multiselect support - know if our component is part of a multiselect operation
  92. virtual CBaseMultiSelectSnapinItem ** PpMultiSelectSnapinItem() { return &m_pMultiSelectSnapinItem;}
  93. public:
  94. //
  95. // Notifications
  96. //
  97. virtual SC ScOnActivate (LPDATAOBJECT lpDataObject, BOOL fActivate);
  98. virtual SC ScOnAddImages (LPDATAOBJECT lpDataObject, IImageList *ipImageList, HSCOPEITEM hscopeitem);
  99. virtual SC ScOnButtonClick (LPDATAOBJECT lpDataObject, MMC_CONSOLE_VERB mcvVerb);
  100. virtual SC ScOnContextHelp (LPDATAOBJECT lpDataObject);
  101. virtual SC ScOnDoubleClick (LPDATAOBJECT lpDataObject);
  102. virtual SC ScOnDelete (LPDATAOBJECT lpDataObject);
  103. virtual SC ScOnListPad (LPDATAOBJECT lpDataObject, BOOL fAttach);
  104. virtual SC ScOnRefresh (LPDATAOBJECT lpDataObject, HSCOPEITEM hscopeitem);
  105. virtual SC ScOnSelect (LPDATAOBJECT lpDataObject, BOOL fScope, BOOL fSelect);
  106. virtual SC ScOnShow (LPDATAOBJECT lpDataObject, BOOL fSelect, HSCOPEITEM hscopeitem);
  107. virtual SC ScOnViewChange (LPDATAOBJECT lpDataObject, long data, long hint);
  108. virtual SC ScOnInitOCX (LPDATAOBJECT lpDataObject, LPUNKNOWN lpOCXUnknown);
  109. public:
  110. //
  111. // Handlers for the various types of view changes.
  112. //
  113. virtual SC ScOnViewChangeDeleteItems (CBaseSnapinItem *pitem);
  114. virtual SC ScOnViewChangeDeleteSingleItem (CBaseSnapinItem *pitem);
  115. virtual SC ScOnViewChangeInsertItem (CBaseSnapinItem *pitem);
  116. virtual SC ScOnViewChangeUpdateItem (CBaseSnapinItem *pitem);
  117. virtual SC ScOnViewChangeUpdateResultItems (CBaseSnapinItem *pitem, BOOL fSelect);
  118. virtual SC ScOnViewChangeUpdateDescriptionBar (CBaseSnapinItem *pitem);
  119. virtual SC ScOnViewChangeHint (CBaseSnapinItem *pitem, long hint);
  120. public:
  121. // IComponent interface
  122. STDMETHOD(Initialize) (LPCONSOLE lpConsole);
  123. STDMETHOD(Notify) (LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, long arg, long param);
  124. STDMETHOD(Destroy) (long cookie);
  125. STDMETHOD(GetResultViewType) (long cookie, LPOLESTR* ppViewType, long* pViewOptions);
  126. STDMETHOD(QueryDataObject) (long cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  127. STDMETHOD(GetDisplayInfo) (RESULTDATAITEM* pResultDataItem);
  128. STDMETHOD(CompareObjects) (LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  129. // IComponent2 interface
  130. STDMETHOD(QueryDispatch) (MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDISPATCH* ppDispatch);
  131. STDMETHOD(GetResultViewType2) (MMC_COOKIE cookie, PRESULT_VIEW_TYPE_INFO pResultViewType);
  132. STDMETHOD(RestoreResultView) (MMC_COOKIE cookie, RESULT_VIEW_TYPE_INFO* pResultViewType);
  133. // IExtendContextMenu interface
  134. STDMETHOD(AddMenuItems) (LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK ipContextMenuCallback, long *pInsertionAllowed);
  135. STDMETHOD(Command) (long nCommandID, LPDATAOBJECT pDataObject);
  136. // IExtendPropertySheet interface
  137. STDMETHOD(CreatePropertyPages) (LPPROPERTYSHEETCALLBACK lpProvider, long handle, LPDATAOBJECT lpDataObject);
  138. STDMETHOD(QueryPagesFor) (LPDATAOBJECT lpDataObject);
  139. // IPersistStreamInit interface
  140. STDMETHOD(GetClassID) (CLSID *pclsid);
  141. STDMETHOD(IsDirty) (void);
  142. STDMETHOD(Load) (IStream *pstream);
  143. STDMETHOD(Save) (IStream *pstream, BOOL fClearDirty);
  144. STDMETHOD(GetSizeMax) (ULARGE_INTEGER *pcbSize);
  145. STDMETHOD(InitNew) (void);
  146. // IResultOwnerData interface
  147. STDMETHOD(CacheHint) (int nStartIndex, int nEndIndex);
  148. STDMETHOD(SortItems) (int nColumn, DWORD dwSortOptions, long lUserParam);
  149. STDMETHOD(FindItem) (LPRESULTFINDINFO pFindinfo, int *pnFoundIndex);
  150. // IResultDataCompareEx interface
  151. STDMETHOD(Compare) (RDCOMPARE * prdc, int * pnResult);
  152. private:
  153. CComponentData * m_pComponentData;
  154. // Interface pointers
  155. IConsolePtr m_ipConsole;
  156. IHeaderCtrlPtr m_ipHeaderCtrl;
  157. IColumnDataPtr m_ipColumnDataPtr;
  158. IResultDataPtr m_ipResultData;
  159. IPropertySheetProviderPtr m_ipPropertySheetProvider;
  160. IConsoleVerbPtr m_ipConsoleVerb;
  161. IImageListPtr m_ipImageList;
  162. // The currently selected scope item in this view.
  163. // This is the node that is in control of the result pane.
  164. // Mostly used to forward calls to the owner of a virtual result pane.
  165. CBaseSnapinItem * m_pitemScopeSelected;
  166. // Pointer to a multiselect snapin item if this component is part of a multiselect operation
  167. CBaseMultiSelectSnapinItem * m_pMultiSelectSnapinItem;
  168. };