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.

234 lines
9.6 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: MSMFSldr.h */
  4. /* Description: Declaration of MSMFSldr */
  5. /* Author: David Janecek */
  6. /*************************************************************************/
  7. #ifndef __MSMFSLDR_H_
  8. #define __MSMFSLDR_H_
  9. #include "resource.h" // main symbols
  10. #include "CBitmap.h"
  11. #include <atlctl.h>
  12. #include "CstUtils.h"
  13. #include "MSMFCntCP.h"
  14. /*************************************************************************/
  15. /* Consts */
  16. /*************************************************************************/
  17. const int cgMaxSldrStates = 5; // the number of button states
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMSMFSldr
  20. class ATL_NO_VTABLE CMSMFSldr :
  21. public CComObjectRootEx<CComSingleThreadModel>,
  22. public CStockPropImpl<CMSMFSldr, IMSMFSldr, &IID_IMSMFSldr, &LIBID_MSMFCNTLib>,
  23. public CComControl<CMSMFSldr>,
  24. public IPersistStreamInitImpl<CMSMFSldr>,
  25. public IOleControlImpl<CMSMFSldr>,
  26. public IOleObjectImpl<CMSMFSldr>,
  27. public IOleInPlaceActiveObjectImpl<CMSMFSldr>,
  28. public IViewObjectExImpl<CMSMFSldr>,
  29. public IOleInPlaceObjectWindowlessImpl<CMSMFSldr>,
  30. public IPersistStorageImpl<CMSMFSldr>,
  31. public ISpecifyPropertyPagesImpl<CMSMFSldr>,
  32. public IQuickActivateImpl<CMSMFSldr>,
  33. public IDataObjectImpl<CMSMFSldr>,
  34. public CComCoClass<CMSMFSldr, &CLSID_MSMFSldr>,
  35. public IProvideClassInfo2Impl<&CLSID_MSMFSldr, &DIID__IMSMFSldr, &LIBID_MSMFCNTLib>,
  36. public IPersistPropertyBagImpl<CMSMFSldr>,
  37. public IConnectionPointContainerImpl<CMSMFSldr>,
  38. public CProxy_IMSMFSldr< CMSMFSldr>,
  39. public CMSMFCntrlUtils<CMSMFSldr> // custom utilities we share across controls
  40. {
  41. public:
  42. CMSMFSldr();
  43. virtual ~CMSMFSldr();
  44. DECLARE_REGISTRY_RESOURCEID(IDR_MSMFSLDR)
  45. DECLARE_PROTECT_FINAL_CONSTRUCT()
  46. BEGIN_COM_MAP(CMSMFSldr)
  47. COM_INTERFACE_ENTRY(IMSMFSldr)
  48. COM_INTERFACE_ENTRY(IDispatch)
  49. COM_INTERFACE_ENTRY(IViewObjectEx)
  50. COM_INTERFACE_ENTRY(IViewObject2)
  51. COM_INTERFACE_ENTRY(IViewObject)
  52. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  53. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  54. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  55. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  56. COM_INTERFACE_ENTRY(IOleControl)
  57. COM_INTERFACE_ENTRY(IOleObject)
  58. COM_INTERFACE_ENTRY(IPersistStreamInit)
  59. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  60. COM_INTERFACE_ENTRY_IMPL_IID(IID_IPersist, IPersistPropertyBag)
  61. COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag)
  62. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  63. COM_INTERFACE_ENTRY(IQuickActivate)
  64. COM_INTERFACE_ENTRY(IPersistStorage)
  65. COM_INTERFACE_ENTRY(IDataObject)
  66. COM_INTERFACE_ENTRY(IProvideClassInfo)
  67. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  68. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  69. END_COM_MAP()
  70. BEGIN_CONNECTION_POINT_MAP(CMSMFSldr)
  71. CONNECTION_POINT_ENTRY(DIID__IMSMFSldr)
  72. END_CONNECTION_POINT_MAP()
  73. BEGIN_PROP_MAP(CMSMFSldr)
  74. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  75. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  76. PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
  77. PROP_ENTRY("ResourceDLL", 19, CLSID_NULL)
  78. PROP_ENTRY("Windowless", 20, CLSID_NULL)
  79. //PROP_ENTRY("TransparentBlitType", 4, CLSID_NULL)
  80. PROP_ENTRY("ThumbStatic",5, CLSID_NULL)
  81. PROP_ENTRY("ThumbHover", 6, CLSID_NULL)
  82. PROP_ENTRY("ThumbPush", 7, CLSID_NULL)
  83. PROP_ENTRY("ThumbDisabled", 8, CLSID_NULL)
  84. PROP_ENTRY("ThumbActive", 9, CLSID_NULL)
  85. PROP_ENTRY("BackStatic",10, CLSID_NULL)
  86. PROP_ENTRY("BackHover", 11, CLSID_NULL)
  87. PROP_ENTRY("BackPush", 12, CLSID_NULL)
  88. PROP_ENTRY("BackDisabled", 13, CLSID_NULL)
  89. PROP_ENTRY("BackActive", 14, CLSID_NULL)
  90. PROP_ENTRY("ThumbWidth", 4, CLSID_NULL)
  91. PROP_ENTRY("Min", 2, CLSID_NULL)
  92. PROP_ENTRY("Max", 3, CLSID_NULL)
  93. PROP_ENTRY("Value", 1, CLSID_NULL)
  94. PROP_ENTRY("XOffset", 17, CLSID_NULL)
  95. PROP_ENTRY("YOffset", 18, CLSID_NULL)
  96. // Example entries
  97. // PROP_ENTRY("Property Description", dispid, clsid)
  98. // PROP_PAGE(CLSID_StockColorPage)
  99. END_PROP_MAP()
  100. BEGIN_MSG_MAP(CMSMFSldr)
  101. MESSAGE_HANDLER(WM_SIZE, OnSize)
  102. MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
  103. MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
  104. MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
  105. MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
  106. MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
  107. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  108. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  109. CHAIN_MSG_MAP(CMSMFCntrlUtils<CMSMFSldr>)
  110. CHAIN_MSG_MAP(CComControl<CMSMFSldr>)
  111. DEFAULT_REFLECTION_HANDLER()
  112. END_MSG_MAP()
  113. LRESULT OnSize(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  114. LRESULT OnButtonDown(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  115. LRESULT OnButtonUp(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  116. LRESULT OnMouseMove(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  117. LRESULT OnSetFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  118. LRESULT OnKillFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  119. LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  120. LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  121. // IViewObjectEx
  122. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  123. // IMSMFSldr
  124. // IMSMFSldr
  125. public:
  126. STDMETHOD(get_Disable)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  127. STDMETHOD(put_Disable)(/*[in]*/ VARIANT_BOOL newVal);
  128. STDMETHOD(get_SldrState)(/*[out, retval]*/ long *pVal);
  129. STDMETHOD(put_SldrState)(/*[in]*/ long newVal);
  130. STDMETHOD(get_ThumbActive)(/*[out, retval]*/ BSTR *pVal);
  131. STDMETHOD(put_ThumbActive)(/*[in]*/ BSTR newVal);
  132. STDMETHOD(get_ThumbDisabled)(/*[out, retval]*/ BSTR *pVal);
  133. STDMETHOD(put_ThumbDisabled)(/*[in]*/ BSTR newVal);
  134. STDMETHOD(get_ThumbPush)(/*[out, retval]*/ BSTR *pVal);
  135. STDMETHOD(put_ThumbPush)(/*[in]*/ BSTR newVal);
  136. STDMETHOD(get_ThumbHover)(/*[out, retval]*/ BSTR *pVal);
  137. STDMETHOD(put_ThumbHover)(/*[in]*/ BSTR newVal);
  138. STDMETHOD(get_ThumbStatic)(/*[out, retval]*/ BSTR *pVal);
  139. STDMETHOD(put_ThumbStatic)(/*[in]*/ BSTR newVal);
  140. STDMETHOD(get_BackActive)(/*[out, retval]*/ BSTR *pVal);
  141. STDMETHOD(put_BackActive)(/*[in]*/ BSTR newVal);
  142. STDMETHOD(get_BackDisabled)(/*[out, retval]*/ BSTR *pVal);
  143. STDMETHOD(put_BackDisabled)(/*[in]*/ BSTR newVal);
  144. STDMETHOD(get_BackPush)(/*[out, retval]*/ BSTR *pVal);
  145. STDMETHOD(put_BackPush)(/*[in]*/ BSTR newVal);
  146. STDMETHOD(get_BackHover)(/*[out, retval]*/ BSTR *pVal);
  147. STDMETHOD(put_BackHover)(/*[in]*/ BSTR newVal);
  148. STDMETHOD(get_BackStatic)(/*[out, retval]*/ BSTR *pVal);
  149. STDMETHOD(put_BackStatic)(/*[in]*/ BSTR newVal);
  150. STDMETHOD(get_XOffset)(/*[out, retval]*/ LONG *pVal);
  151. STDMETHOD(put_XOffset)(/*[in]*/ LONG newVal);
  152. STDMETHOD(get_YOffset)(/*[out, retval]*/ LONG *pVal);
  153. STDMETHOD(put_YOffset)(/*[in]*/ LONG newVal);
  154. STDMETHOD(get_ThumbWidth)(/*[out, retval]*/ LONG *pVal);
  155. STDMETHOD(put_ThumbWidth)(/*[in]*/ LONG newVal);
  156. STDMETHOD(get_Max)(/*[out, retval]*/ float *pVal);
  157. STDMETHOD(put_Max)(/*[in]*/ float newVal);
  158. STDMETHOD(get_Min)(/*[out, retval]*/ float *pVal);
  159. STDMETHOD(put_Min)(/*[in]*/ float newVal);
  160. STDMETHOD(get_Value)(/*[out, retval]*/ float *pVal);
  161. STDMETHOD(put_Value)(/*[in]*/ float newVal);
  162. USE_MF_RESOURCEDLL // replaces the two lines below
  163. //STDMETHOD(get_ResourceDLL)(/*[out, retval]*/ BSTR *pVal);
  164. //STDMETHOD(put_ResourceDLL)(/*[in]*/ BSTR newVal);
  165. USE_MF_WINDOWLESS_ACTIVATION
  166. USE_MF_TRANSPARENT_FLAG
  167. HRESULT OnDraw(ATL_DRAWINFO& di);
  168. // IOleInPlaceObjectWindowlessImpl
  169. STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip);
  170. enum SldrState {Static = 0, Hover = 1, Push = 2, Disabled = 3, Active = 4};
  171. USE_MF_OVERWRITES
  172. USE_MF_CLASSSTYLE // used to overwrite default class, so we avoid flickers
  173. public: // member variable that have to be public due to ATL
  174. STDMETHOD(get_ArrowKeyDecrement)(/*[out, retval]*/ float *pVal);
  175. STDMETHOD(put_ArrowKeyDecrement)(/*[in]*/ float newVal);
  176. STDMETHOD(get_ArrowKeyIncrement)(/*[out, retval]*/ FLOAT *pVal);
  177. STDMETHOD(put_ArrowKeyIncrement)(/*[in]*/ FLOAT newVal);
  178. OLE_COLOR m_clrBackColor; // stock property implemeted in the CStockPropImpl
  179. private:
  180. FLOAT m_fValue;
  181. FLOAT m_fMin;
  182. FLOAT m_fMax;
  183. LONG m_lXOffset;
  184. LONG m_lYOffset;
  185. LONG m_lThumbWidth;
  186. FLOAT m_fKeyIncrement;
  187. FLOAT m_fKeyDecrement;
  188. CBitmap* m_pThumbBitmap[cgMaxSldrStates];
  189. CComBSTR m_bstrThumbFilename[cgMaxSldrStates]; // filenames containing the thumb images
  190. CBitmap* m_pBackBitmap[cgMaxSldrStates];
  191. CComBSTR m_bstrBackFilename[cgMaxSldrStates]; // filenames containing the background images
  192. SldrState m_nEntry;
  193. RECT m_rcThumb; // position for the thumb
  194. protected:
  195. void Init();
  196. HRESULT RecalculateValue();
  197. HRESULT RecalculateTumbPos(); // Centers the thumb rect around the m_fValue
  198. HRESULT PutThumbImage(BSTR strFilename, int nEntry);
  199. HRESULT PutBackImage(BSTR strFilename, int nEntry);
  200. HRESULT SetSliderState(SldrState sldrState);
  201. HRESULT SetThumbPos(LONG xPos);
  202. HRESULT OffsetX(LONG& xPos);
  203. HRESULT FitValue();
  204. bool PtOnSlider(LONG x, LONG y);
  205. bool PtOnSlider(POINT pos);
  206. bool PtOnThumb(LONG x, LONG y);
  207. bool PtOnThumb(POINT pos);
  208. };
  209. #endif //__MSMFSLDR_H_
  210. /*************************************************************************/
  211. /* End of file: MSMFSldr.h */
  212. /*************************************************************************/