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.

230 lines
6.0 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: ResCtrl.h
  4. //
  5. // Synopsis: This file holds the declaration of the
  6. // of CResCtrl class
  7. //
  8. // History: 01/15/2001 serdarun Created
  9. //
  10. // Copyright (C) 2000-2001 Microsoft Corporation
  11. // All rights reserved.
  12. //
  13. //#--------------------------------------------------------------
  14. #ifndef __RESCTRL_H_
  15. #define __RESCTRL_H_
  16. #include "resource.h" // main symbols
  17. #include <atlctl.h>
  18. #include "Wbemidl.h"
  19. #include "elementmgr.h"
  20. #include "satrace.h"
  21. #include "getvalue.h"
  22. #include "mem.h"
  23. #include <string>
  24. #include <map>
  25. using namespace std;
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CResCtrl
  28. class ATL_NO_VTABLE CResCtrl :
  29. public CComObjectRootEx<CComSingleThreadModel>,
  30. public IDispatchImpl<IResCtrl, &IID_IResCtrl, &LIBID_LOCALUIRESOURCELib>,
  31. public CComControl<CResCtrl>,
  32. public IOleControlImpl<CResCtrl>,
  33. public IOleObjectImpl<CResCtrl>,
  34. public IOleInPlaceActiveObjectImpl<CResCtrl>,
  35. public IViewObjectExImpl<CResCtrl>,
  36. public IOleInPlaceObjectWindowlessImpl<CResCtrl>,
  37. public CComCoClass<CResCtrl, &CLSID_ResCtrl>,
  38. public IWbemObjectSink
  39. {
  40. public:
  41. CResCtrl()
  42. {
  43. }
  44. DECLARE_REGISTRY_RESOURCEID(IDR_RESCTRL)
  45. DECLARE_PROTECT_FINAL_CONSTRUCT()
  46. DECLARE_CLASSFACTORY_SINGLETON (CResCtrl)
  47. BEGIN_COM_MAP(CResCtrl)
  48. COM_INTERFACE_ENTRY(IResCtrl)
  49. COM_INTERFACE_ENTRY(IDispatch)
  50. COM_INTERFACE_ENTRY(IViewObjectEx)
  51. COM_INTERFACE_ENTRY(IViewObject2)
  52. COM_INTERFACE_ENTRY(IViewObject)
  53. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  54. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  55. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  56. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  57. COM_INTERFACE_ENTRY(IOleControl)
  58. COM_INTERFACE_ENTRY(IOleObject)
  59. COM_INTERFACE_ENTRY(IWbemObjectSink)
  60. END_COM_MAP()
  61. BEGIN_PROP_MAP(CResCtrl)
  62. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  63. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  64. // Example entries
  65. // PROP_ENTRY("Property Description", dispid, clsid)
  66. // PROP_PAGE(CLSID_StockColorPage)
  67. END_PROP_MAP()
  68. BEGIN_MSG_MAP(CResCtrl)
  69. CHAIN_MSG_MAP(CComControl<CResCtrl>)
  70. DEFAULT_REFLECTION_HANDLER()
  71. END_MSG_MAP()
  72. // Handler prototypes:
  73. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  74. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  75. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  76. // IViewObjectEx
  77. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  78. // IResCtrl
  79. private:
  80. //
  81. // method for determining the resource dll directory
  82. //
  83. HRESULT GetResourceDirectory (
  84. /*[out]*/ wstring& wstrResourceDir
  85. );
  86. HRESULT ExpandSz(IN const TCHAR *lpszStr, OUT LPTSTR *ppszStr);
  87. //
  88. // sets the language id
  89. //
  90. void SetLangID(DWORD * dwLangID);
  91. //
  92. // mapping of state and icon information for each resource
  93. //
  94. typedef map< LONG, HICON > ResourceIconMap;
  95. typedef ResourceIconMap::iterator ResourceIconMapIterator;
  96. //
  97. // struct for each localui resource
  98. //
  99. typedef struct
  100. {
  101. LONG lState;
  102. ResourceIconMap mapResIcon;
  103. } ResourceStruct,*ResourceStructPtr;
  104. //
  105. // mapping of resource name and localui resource
  106. //
  107. typedef map< wstring, ResourceStructPtr > ResourceMap;
  108. typedef ResourceMap::iterator ResourceMapIterator;
  109. //
  110. // contains all of the localui resources
  111. //
  112. ResourceMap m_ResourceMap;
  113. //
  114. // mapping of resource names and their merits
  115. //
  116. typedef map< DWORD, wstring> MeritMap;
  117. typedef MeritMap::iterator MeritMapIterator;
  118. //
  119. // contains localui resource names and merits
  120. //
  121. MeritMap m_MeritMap;
  122. //
  123. // resource directory
  124. //
  125. wstring m_wstrResourceDir;
  126. //
  127. // number of localui resources
  128. //
  129. LONG m_lResourceCount;
  130. CComPtr <IWbemServices> m_pWbemServices;
  131. //
  132. // method obtaining resource information from element manager
  133. //
  134. STDMETHOD(GetLocalUIResources)
  135. (
  136. void
  137. );
  138. //
  139. // initializes wbem for localui resource events
  140. //
  141. STDMETHOD(InitializeWbemSink)
  142. (
  143. void
  144. );
  145. //
  146. // loads icons for each resource web element
  147. //
  148. STDMETHOD(AddIconResource)
  149. (
  150. /*[in]*/IWebElement * pElement
  151. );
  152. //
  153. // converts a hex digit to base 10 number
  154. //
  155. ULONG HexCharToULong(WCHAR wch);
  156. //
  157. // converts a hex string to unsigned long
  158. //
  159. ULONG HexStringToULong(wstring wsHexString);
  160. public:
  161. //
  162. // called just after constructor, initializes the component
  163. //
  164. STDMETHOD(FinalConstruct)(void);
  165. //
  166. // called just before destructor, releases resources
  167. //
  168. STDMETHOD(FinalRelease)(void);
  169. //
  170. // ---------IWbemUnboundObjectSink interface methods----------
  171. //
  172. STDMETHOD(Indicate) (
  173. /*[in]*/ LONG lObjectCount,
  174. /*[in]*/ IWbemClassObject **ppObjArray
  175. );
  176. STDMETHOD(SetStatus) (
  177. /*[in]*/ LONG lFlags,
  178. /*[in]*/ HRESULT hResult,
  179. /*[in]*/ BSTR strParam,
  180. /*[in]*/ IWbemClassObject *pObjParam
  181. );
  182. //
  183. // draws the icons
  184. //
  185. HRESULT OnDraw(ATL_DRAWINFO& di);
  186. };
  187. #endif //__RESCTRL_H_