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.

253 lines
8.8 KiB

  1. // SysInfo.h : the main OLE interface class to MSInfo.
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. #pragma once // MSINFO_SYSINFO_H
  5. // This hack is required because we may be building in an environment
  6. // which doesn't have a late enough version of rpcndr.h
  7. #if __RPCNDR_H_VERSION__ < 440
  8. #define __RPCNDR_H_VERSION__ 440
  9. #define MIDL_INTERFACE(x) interface
  10. #endif
  11. #ifndef __mmc_h__
  12. #include <mmc.h> // ..\..\..\public\sdk\inc
  13. #endif // __mmc_h__
  14. class CSystemInfoScope;
  15. class CDataCategory;
  16. #include "StdAfx.h"
  17. #include "CompData.h"
  18. #include "Toolset.h"
  19. /*
  20. * class CSystemInfo - The object that handles the result item User Interface
  21. * in MMC.
  22. */
  23. extern DWORD WINAPI ThreadRefresh(void * pArg);
  24. class CThreadingRefresh;
  25. class CSystemInfo :
  26. public IComponent,
  27. public IExtendContextMenu,
  28. public IExtendControlbar,
  29. public IExtendPropertySheet,
  30. public IExtendTaskPad,
  31. public IResultDataCompare,
  32. public CComObjectRoot
  33. {
  34. BEGIN_COM_MAP(CSystemInfo)
  35. COM_INTERFACE_ENTRY(IComponent)
  36. COM_INTERFACE_ENTRY(IExtendContextMenu)
  37. COM_INTERFACE_ENTRY(IExtendControlbar)
  38. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  39. COM_INTERFACE_ENTRY(IExtendTaskPad)
  40. COM_INTERFACE_ENTRY(IResultDataCompare)
  41. END_COM_MAP()
  42. friend DWORD WINAPI ThreadRefresh(void * pArg);
  43. friend class CThreadingRefresh;
  44. public:
  45. CSystemInfo();
  46. ~CSystemInfo();
  47. // IComponent interface methods
  48. public:
  49. STDMETHOD(Initialize)(LPCONSOLE lpConsole);
  50. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  51. STDMETHOD(Destroy)(MMC_COOKIE cookie);
  52. STDMETHOD(GetResultViewType)(MMC_COOKIE cookie, LPOLESTR *ppViewType, long *pViewOptions);
  53. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT *ppDataObject);
  54. STDMETHOD(GetDisplayInfo)(LPRESULTDATAITEM pResult);
  55. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  56. // Public access functions
  57. public:
  58. HRESULT SetIComponentData(CSystemInfoScope *pData);
  59. // IExtendContextMenu interface members
  60. public:
  61. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallback,
  62. long *pInsertionAllowed);
  63. STDMETHOD(Command)(long lCommandID, LPDATAOBJECT pDataObject);
  64. // IExtendControlbar interface members
  65. public:
  66. STDMETHOD(SetControlbar)(LPCONTROLBAR pControlbar);
  67. STDMETHOD(ControlbarNotify)(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  68. // IExtendPropertySheet interface members
  69. public:
  70. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider, LONG_PTR handle,
  71. LPDATAOBJECT lpDataObject);
  72. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  73. // IResultDataCompare interface members
  74. public:
  75. STDMETHOD(Compare)(LRESULT, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int *pnResult);
  76. // IExtendTaskPad interface members
  77. public:
  78. STDMETHOD(TaskNotify)(LPDATAOBJECT lpDataObject, VARIANT *pvarg, VARIANT *pvparam);
  79. STDMETHOD(EnumTasks)(LPDATAOBJECT lpDataObject, LPOLESTR szTask, LPENUMTASK *ppEnumTask);
  80. STDMETHOD(GetListPadInfo)(LPOLESTR szGroup, MMC_LISTPAD_INFO *lpListPadInfo);
  81. STDMETHOD(GetTitle)(BSTR szGroup, LPOLESTR *pszTitle);
  82. STDMETHOD(GetBackground)(BSTR szGroup, MMC_TASK_DISPLAY_OBJECT * pTDO);
  83. STDMETHOD(GetDescriptiveText)(BSTR szGroup, LPOLESTR *pszDescriptiveText);
  84. // Private encapsulation methods.
  85. private:
  86. #if 0
  87. // For if we add multi-select data objects.
  88. HRESULT QueryMultiSelectDataObject(long cookie, DATA_OBJECT_TYPES type,
  89. LPDATAOBJECT *ppDataObject);
  90. #endif
  91. #if 0
  92. // For if we pre-load resources.
  93. void LoadResources();
  94. #endif
  95. // AddToTopMenu is a convenience wrapper for AddToMenu
  96. HRESULT AddToTopMenu(LPCONTEXTMENUCALLBACK lpCallback, long lNameResource,
  97. long lStatusResource, long lCommandID)
  98. {
  99. return AddToMenu(lpCallback, lNameResource, lStatusResource, lCommandID,
  100. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  101. }
  102. // AddToTaskMenu is a convenience wrapper for AddToMenu
  103. HRESULT AddToTaskMenu(LPCONTEXTMENUCALLBACK lpCallback, long lNameResource,
  104. long lStatusResource, long lCommandID)
  105. {
  106. return AddToMenu(lpCallback, lNameResource, lStatusResource, lCommandID,
  107. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  108. }
  109. HRESULT AddToMenu(LPCONTEXTMENUCALLBACK lpCallback, long lNameResource,
  110. long lStatusResource, long lCommandID, long lInsertionPoint);
  111. HRESULT EnableToolbar(BOOL fEnable);
  112. HRESULT EnableSupportTools(BOOL fEnable);
  113. HRESULT AddToolbarButtons(LPTOOLBAR pToolbar);
  114. // Event helper functions (found in REvents.cpp)
  115. private:
  116. HRESULT ClearResultsPane();
  117. HRESULT EnumerateValues(CFolder *pfolCategory);
  118. HRESULT HandleStandardVerbs(BOOL fScope, LPDATAOBJECT lpDataObject);
  119. void SetInitialVerbState(BOOL fScope);
  120. HRESULT SetResultHeaderColumns(CFolder *pfolCategory);
  121. // Notification events (found in REvents.cpp)
  122. private:
  123. HRESULT DisplayFolder(CFolder *pFolder);
  124. HRESULT OnActivate(LPDATAOBJECT pDataObject, LPARAM fActive);
  125. HRESULT OnAddImages(LPDATAOBJECT pDataObject, LPIMAGELIST pImageList, HSCOPEITEM hSelectedItem);
  126. HRESULT OnButtonClick(LPDATAOBJECT pDataObject, LPARAM idButton);
  127. HRESULT OnContextHelp(LPDATAOBJECT pDataObject);
  128. HRESULT OnControlbarSelect(BOOL fDeselectAll, LPARAM lSelection, LPDATAOBJECT pDataObject);
  129. HRESULT OnDoubleClick(LPDATAOBJECT pDataObject);
  130. HRESULT OnListPad();
  131. HRESULT OnMenuButtonClick(LPDATAOBJECT *pDataObject, LPMENUBUTTONDATA pMenuButton);
  132. HRESULT OnPrint();
  133. HRESULT OnProperties(LPDATAOBJECT pDataObject);
  134. HRESULT OnPropertyChange(LPDATAOBJECT pDataObject);
  135. HRESULT OnRefresh(LPDATAOBJECT pDataObject);
  136. HRESULT OnSelect(LPDATAOBJECT pDataObject, LPARAM lSelection);
  137. HRESULT OnShow(LPDATAOBJECT pDataObject, LPARAM fSelect, HSCOPEITEM hSelectedItem);
  138. HRESULT OnSnapinHelp(LPDATAOBJECT lpDataObject);
  139. HRESULT OnUpdateView(LPARAM arg);
  140. // Member access functions.
  141. private:
  142. LPCOMPONENTDATA pComponentData() const { return m_pComponentData; }
  143. LPEXTENDCONTEXTMENU pExtendContextMenu() const
  144. {
  145. LPEXTENDCONTEXTMENU pInterface;
  146. HRESULT hr = m_pComponentData->QueryInterface(IID_IExtendContextMenu, (void **)&pInterface);
  147. ASSERT(hr == S_OK);
  148. return pInterface;
  149. }
  150. LPEXTENDPROPERTYSHEET pExtendPropertySheet() const
  151. {
  152. LPEXTENDPROPERTYSHEET pInterface;
  153. HRESULT hr = m_pComponentData->QueryInterface(IID_IExtendPropertySheet,
  154. (void **) &pInterface);
  155. ASSERT(hr == S_OK);
  156. return pInterface;
  157. }
  158. LPCONSOLE pConsole() const { return m_pConsole; }
  159. LPCONSOLEVERB pConsoleVerb() const { return m_pConsoleVerb; }
  160. LPTOOLBAR ptbItems() const { return m_pToolbar; }
  161. LPMENUBUTTON pmnbSupportTools() const { return m_pMenuButton; }
  162. LPRESULTDATA pResult() const { return m_pResult; }
  163. LPCONTROLBAR pControlbar() const { return m_pControlbar; }
  164. LPHEADERCTRL pHeaderCtrl() const { return m_pHeader; }
  165. // Private enumeration types.
  166. private:
  167. // The IDs for the toolbar buttons so that our callback can switch off
  168. // of the ID to process the right command based on the Toolbar selection.
  169. // Order is relevant here, as are the first and last elements in the
  170. // enum. If any of these criteria change, see the notes in
  171. // AddToolbarButtons.
  172. enum ToolbarButtonID {
  173. IDM_TBB_SAVE = 1,
  174. IDM_TBB_OPEN = IDM_TBB_SAVE + 1,
  175. IDM_TBB_REPORT = IDM_TBB_OPEN + 1,
  176. #if 0
  177. IDM_TBB_PRINT = IDM_TBB_REPORT + 1,
  178. #endif
  179. IDM_TBB_FIND = IDM_TBB_REPORT + 1
  180. };
  181. enum { IDM_SUPPORT = 22222, IDM_TOOL1 = IDM_SUPPORT + 1 };
  182. // Private data members.
  183. private:
  184. // CUSTOM_VIEW_ID m_CustomViewID;
  185. #ifdef _DEBUG
  186. BOOL m_bInitializedC;
  187. #endif
  188. // Our snap-in's interface.
  189. LPCOMPONENTDATA m_pComponentData; // Pointer to IComponentData interface
  190. // MMC queried interfaces
  191. LPCONSOLE m_pConsole; // Pointer to IConsole interface
  192. LPCONTROLBAR m_pControlbar; // Pointer to IControlbar interface.
  193. LPHEADERCTRL m_pHeader; // Pointer to IHeaderCtrl interface.
  194. LPRESULTDATA m_pResult; // Pointer to IResultData interface.
  195. LPIMAGELIST m_pImageResult; // Pointer to IImageList interface
  196. LPCONSOLEVERB m_pConsoleVerb; // Pointer to IConsoleVerb interface
  197. LPTOOLBAR m_pToolbar; // Pointer to IToolbar interface
  198. LPMENUBUTTON m_pMenuButton; // Pointer to IMenuButton interface
  199. LPDISPLAYHELP m_pDisplayHelp;
  200. LPCONSOLE2 m_pConsole2;
  201. // A pointer to the last folder in which we selected any result-pane items.
  202. CFolder *m_pfLast;
  203. CFolder * m_pLastRefreshedFolder;
  204. // Internal menu item for the Support Tools menu
  205. CMenu m_mnuSupport;
  206. // Internal list of support tools for the Support Tools MenuButton
  207. CToolList *m_plistTools;
  208. // Internal list of CViewObject items
  209. CViewObjectList m_lstView;
  210. CString m_strRefreshMessage; // loaded from resource in Initialize()
  211. CString m_strNoOCXMessage;
  212. public:
  213. const LPARAM lparamRefreshIndicator; // value assigned in CSystemInfo contstructor
  214. const LPARAM lparamNoOCXIndicator; // value assigned in CSystemInfo contstructor
  215. void SetStatusText(LPCTSTR szText);
  216. void SetStatusText(UINT nResID);
  217. void SelectLine(int iLine);
  218. void SetRefreshing(LPARAM lparamMessage);
  219. CMapStringToPtr m_mapCLSIDToIUnknown;
  220. }; // CSystemInfo