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.

296 lines
9.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: DsplMgr2.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // DsplMgr2.h : Declaration of the CDsplMgr2
  11. #ifndef __DSPLMGR2_H_
  12. #define __DSPLMGR2_H_
  13. //#include "taskpad.h"
  14. #include "resource.h" // main symbols
  15. using namespace ATL;
  16. #define DISPLAY_MANAGER_WALLPAPER 1
  17. #define DISPLAY_MANAGER_PATTERN 2
  18. #define DISPLAY_MANAGER_PATTERN_CHILD 3
  19. #define IDM_CENTER 1
  20. #define IDM_TILE 2
  21. #define IDM_STRETCH 3
  22. #define IDM_CUSTOMPAD 4
  23. #define IDM_TASKPAD 5
  24. #define IDM_TASKPAD_LISTVIEW 6
  25. #define IDM_DEFAULT_LISTVIEW 7
  26. #define IDM_DELETECHILDREN 8
  27. #define IDM_RENAMEROOT 9
  28. #define IDM_TASKPAD_WALLPAPER_OPTIONS 10
  29. #define IDM_CHANGEICON 11
  30. #define IDM_RENAMEWALL 12
  31. #define IDM_PRELOAD 13
  32. #define IDM_CONSOLEVERB 14
  33. class CComponent;
  34. struct lParamWallpaper {
  35. OLECHAR filename[MAX_PATH];
  36. };
  37. LPOLESTR CoTaskDupString (LPOLESTR szString);
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CDsplMgr2
  40. class ATL_NO_VTABLE CDsplMgr2 :
  41. public CComObjectRootEx<CComSingleThreadModel>,
  42. public CComCoClass<CDsplMgr2, &CLSID_DsplMgr2>,
  43. public IPersistStream,
  44. public IComponentData
  45. {
  46. public:
  47. CDsplMgr2();
  48. ~CDsplMgr2();
  49. DECLARE_REGISTRY_RESOURCEID(IDR_DSPLMGR2)
  50. DECLARE_NOT_AGGREGATABLE(CDsplMgr2)
  51. BEGIN_COM_MAP(CDsplMgr2)
  52. COM_INTERFACE_ENTRY(IComponentData)
  53. COM_INTERFACE_ENTRY(IPersistStream)
  54. END_COM_MAP()
  55. // IComponentData interface members
  56. public:
  57. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  58. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  59. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, long arg, long param);
  60. STDMETHOD(Destroy)();
  61. STDMETHOD(QueryDataObject)(long cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  62. STDMETHOD(GetDisplayInfo)(SCOPEDATAITEM* pScopeDataItem);
  63. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  64. // IPersistStream interface members
  65. STDMETHOD(GetClassID)(CLSID *pClassID);
  66. STDMETHOD(IsDirty)();
  67. STDMETHOD(Load)(IStream *pStream);
  68. STDMETHOD(Save)(IStream *pStream, BOOL fClearDirty);
  69. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  70. public:
  71. long GetViewMode () { return m_ViewMode; }
  72. void SetViewMode (long vm) { m_ViewMode = vm; }
  73. HSCOPEITEM GetRoot () { return m_rootscopeitem; }
  74. HSCOPEITEM GetWallPaperNode () { return m_WallPaperNodeID; }
  75. BOOL GetPreload () { return m_bPreload; }
  76. void myDeleteItem (HSCOPEITEM hsi, BOOL fDeleteThis) { m_lpIConsoleNameSpace->DeleteItem (hsi, fDeleteThis); }
  77. void myRenameItem (HSCOPEITEM hsi, LPOLESTR szName);
  78. void myChangeIcon (void);
  79. void myPreLoad (void);
  80. private:
  81. HRESULT OnExpand (LPDATAOBJECT pDataObject, long arg, long param);
  82. private:
  83. IConsole * m_lpIConsole;
  84. IConsoleNameSpace * m_lpIConsoleNameSpace;
  85. IImageList * m_lpIImageList;
  86. long m_ViewMode;
  87. ATL::CComObject<class CComponent> * m_pComponent;
  88. HSCOPEITEM m_rootscopeitem;
  89. HSCOPEITEM m_patternscopeitem;
  90. HSCOPEITEM m_WallPaperNodeID; // 0 == unexpanded...
  91. BOOL m_toggle;
  92. BOOL m_bPreload;
  93. };
  94. class CEnumTasks : public IEnumTASK
  95. {
  96. public:
  97. CEnumTasks();
  98. ~CEnumTasks();
  99. public:
  100. // IUnknown implementation
  101. STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  102. STDMETHOD_(ULONG, AddRef) ();
  103. STDMETHOD_(ULONG, Release) ();
  104. private:
  105. ULONG m_refs;
  106. public:
  107. // IEnumTASKS implementation
  108. STDMETHOD(Next) (ULONG celt, MMC_TASK *rgelt, ULONG *pceltFetched);
  109. STDMETHOD(Skip) (ULONG celt);
  110. STDMETHOD(Reset)();
  111. STDMETHOD(Clone)(IEnumTASK **ppenum);
  112. private:
  113. ULONG m_index;
  114. public:
  115. HRESULT Init (IDataObject * pdo, LPOLESTR szTaskGroup);
  116. private:
  117. void GetBitmaps (void);
  118. HRESULT EnumBitmaps (ULONG celt, MMC_TASK *rgelt, ULONG *pceltFetched);
  119. HRESULT EnumOptions (ULONG celt, MMC_TASK *rgelt, ULONG *pceltFetched);
  120. private:
  121. int m_type; // task grouping mechanism
  122. TCHAR * m_bmps;
  123. };
  124. class CDataObject:
  125. public IDataObject,
  126. public CComObjectRoot
  127. {
  128. public:
  129. // ATL Maps
  130. DECLARE_NOT_AGGREGATABLE(CDataObject)
  131. BEGIN_COM_MAP(CDataObject)
  132. COM_INTERFACE_ENTRY(IDataObject)
  133. END_COM_MAP()
  134. private:
  135. CDataObject() {};
  136. public:
  137. CDataObject(long cookie, DATA_OBJECT_TYPES type);
  138. ~CDataObject();
  139. //
  140. // IUnknown overrides
  141. //
  142. STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  143. STDMETHOD_(ULONG, AddRef) ();
  144. STDMETHOD_(ULONG, Release) ();
  145. //
  146. // IDataObject overrides
  147. //
  148. STDMETHOD(GetDataHere) (FORMATETC *pformatetc, STGMEDIUM *pmedium);
  149. // Not Implemented
  150. private:
  151. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
  152. { return E_NOTIMPL; };
  153. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
  154. { return E_NOTIMPL; };
  155. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
  156. { return E_NOTIMPL; };
  157. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  158. { return E_NOTIMPL; };
  159. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  160. { return E_NOTIMPL; };
  161. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  162. { return E_NOTIMPL; };
  163. STDMETHOD(DUnadvise)(DWORD dwConnection)
  164. { return E_NOTIMPL; };
  165. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  166. { return E_NOTIMPL; };
  167. public: // my methods
  168. long GetCookie () { return m_cookie; }
  169. DATA_OBJECT_TYPES GetType () { return m_type; }
  170. void SetPreload (BOOL b) { m_bPreload = b; }
  171. private:
  172. ULONG m_ref; // object reference counter
  173. long m_cookie;
  174. DATA_OBJECT_TYPES m_type;
  175. BOOL m_bPreload;
  176. /*
  177. ULONG m_cRefs; // object refcount
  178. ULONG m_ulCookie; // what this obj refers to
  179. DATA_OBJECT_TYPES m_Context; // context in which this was created
  180. COOKIETYPE m_Type; // how to interpret _ulCookie
  181. CComponentData *m_pcd; // NULL if created by csnapin
  182. */
  183. public:
  184. static UINT s_cfInternal; // Our custom clipboard format
  185. static UINT s_cfDisplayName; // Our test for a node
  186. static UINT s_cfNodeType;
  187. static UINT s_cfSnapinClsid;
  188. static UINT s_cfSnapinPreloads;
  189. };
  190. class CComponent:
  191. public IExtendTaskPad,
  192. public IComponent,
  193. public IExtendContextMenu,
  194. public CComObjectRoot
  195. {
  196. public:
  197. // ATL Maps
  198. DECLARE_NOT_AGGREGATABLE(CComponent)
  199. BEGIN_COM_MAP(CComponent)
  200. COM_INTERFACE_ENTRY(IComponent)
  201. COM_INTERFACE_ENTRY(IExtendTaskPad)
  202. COM_INTERFACE_ENTRY(IExtendContextMenu)
  203. END_COM_MAP()
  204. CComponent();
  205. ~CComponent();
  206. //
  207. // IComponent interface members
  208. //
  209. STDMETHOD(Initialize) (LPCONSOLE lpConsole);
  210. STDMETHOD(Notify) (LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, long arg, long param);
  211. STDMETHOD(Destroy) (long cookie);
  212. STDMETHOD(GetResultViewType) (long cookie, LPOLESTR* ppViewType, long* pViewOptions);
  213. STDMETHOD(QueryDataObject) (long cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  214. STDMETHOD(GetDisplayInfo) (RESULTDATAITEM* pResultDataItem);
  215. STDMETHOD(CompareObjects) (LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  216. // IExtendContextMenu
  217. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown, long *pInsertionAllowed);
  218. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  219. // IExtendTaskPad interface members
  220. STDMETHOD(TaskNotify )(IDataObject * pdo, VARIANT * pvarg, VARIANT * pvparam);
  221. STDMETHOD(GetTitle )(LPOLESTR szGroup, LPOLESTR * szTitle);
  222. STDMETHOD(GetDescriptiveText)(LPOLESTR szGroup, LPOLESTR * szText);
  223. STDMETHOD(GetBackground )(LPOLESTR szGroup, MMC_TASK_DISPLAY_OBJECT * pTDO);
  224. STDMETHOD(EnumTasks )(IDataObject * pdo, BSTR szTaskGroup, IEnumTASK** ppEnumTASK);
  225. STDMETHOD(GetListPadInfo )(LPOLESTR szGroup, MMC_LISTPAD_INFO * pListPadInfo);
  226. // public
  227. void SetComponentData (CDsplMgr2 * pComponentData) { m_pComponentData = pComponentData; }
  228. long GetViewMode ();
  229. private:
  230. IResultData * m_pResultData;
  231. IHeaderCtrl * m_pHeaderCtrl;
  232. CDsplMgr2 * m_pComponentData; // the guy who created me
  233. UINT m_IsTaskPad; // IDM_CUSTOMPAD or IDM_TASKPAD
  234. LPCONSOLE m_pConsole; // from MMC
  235. long m_TaskPadCount;
  236. BOOL m_toggle;
  237. BOOL m_toggleEntry; // test "Change..." button
  238. private:
  239. HRESULT OnShow (LPDATAOBJECT pDataObject, long arg, long param);
  240. HRESULT OnAddImages (LPDATAOBJECT pDataObject, long arg, long param);
  241. HRESULT OnDblClick (LPDATAOBJECT pDataObject, long arg, long param);
  242. HRESULT OnViewChange (LPDATAOBJECT pDataObject, long arg, long param);
  243. HRESULT OnListPad (LPDATAOBJECT pDataObject, long arg, long param);
  244. HRESULT OnRestoreView(LPDATAOBJECT pDataObject, long arg, long param);
  245. void TestConsoleVerb(void);
  246. };
  247. LPOLESTR CoTaskDupString (LPOLESTR szString);
  248. void CoTaskFreeString (LPOLESTR szString);
  249. #endif //__DSPLMGR2_H_