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.

220 lines
5.8 KiB

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