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.

240 lines
10 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: MSMFBBtn.h */
  4. /* Description: Declaration of CMSMFBBtn */
  5. /* Author: David Janecek */
  6. /*************************************************************************/
  7. #ifndef __MSMFBBTN_H_
  8. #define __MSMFBBTN_H_
  9. #include "resource.h" // main symbols
  10. #include <atlctl.h>
  11. #include "CstUtils.h"
  12. #include "ctext.h"
  13. #include "cbitmap.h"
  14. #include "MSMFCntCP.h"
  15. /*************************************************************************/
  16. /* Consts */
  17. /*************************************************************************/
  18. const int cgMaxBtnStates = 5; // the number of button states
  19. /*************************************************************************/
  20. /* Class: CMSMFBBtn */
  21. /*************************************************************************/
  22. class ATL_NO_VTABLE CMSMFBBtn :
  23. public CComObjectRootEx<CComSingleThreadModel>,
  24. //public IDispatchImpl<IMSMFBBtn, &IID_IMSMFBBtn, &LIBID_BBTNLib>,
  25. public CStockPropImpl<CMSMFBBtn, IMSMFBBtn, &IID_IMSMFBBtn, &LIBID_MSMFCNTLib>,
  26. public CComControl<CMSMFBBtn>,
  27. public IPersistStreamInitImpl<CMSMFBBtn>,
  28. public IOleControlImpl<CMSMFBBtn>,
  29. public IOleObjectImpl<CMSMFBBtn>,
  30. public IOleInPlaceActiveObjectImpl<CMSMFBBtn>,
  31. public IViewObjectExImpl<CMSMFBBtn>,
  32. public IOleInPlaceObjectWindowlessImpl<CMSMFBBtn>,
  33. public IPersistPropertyBagImpl<CMSMFBBtn>,
  34. public CComCoClass<CMSMFBBtn, &CLSID_MSMFBBtn>,
  35. public IProvideClassInfo2Impl<&CLSID_MSMFBBtn, &DIID__IMSMFBBtn, &LIBID_MSMFCNTLib>,
  36. public IObjectSafetyImpl<CMSMFBBtn, INTERFACESAFE_FOR_UNTRUSTED_CALLER| INTERFACESAFE_FOR_UNTRUSTED_DATA>,
  37. #ifdef _WMP
  38. public IWMPUIPluginImpl<CMSMFBBtn>,
  39. public IWMPUIPluginEventsImpl,
  40. #endif
  41. public IConnectionPointContainerImpl<CMSMFBBtn>,
  42. public CProxy_IMSMFBBtn< CMSMFBBtn >,
  43. public CMSMFCntrlUtils<CMSMFBBtn> // custom utilities we share across controls
  44. {
  45. public:
  46. CMSMFBBtn();
  47. virtual ~CMSMFBBtn();
  48. DECLARE_REGISTRY_RESOURCEID(IDR_MSMFBBTN)
  49. DECLARE_PROTECT_FINAL_CONSTRUCT()
  50. BEGIN_COM_MAP(CMSMFBBtn)
  51. COM_INTERFACE_ENTRY(IMSMFBBtn)
  52. COM_INTERFACE_ENTRY(IDispatch)
  53. COM_INTERFACE_ENTRY(IViewObjectEx)
  54. COM_INTERFACE_ENTRY(IViewObject2)
  55. COM_INTERFACE_ENTRY(IViewObject)
  56. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  57. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  58. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  59. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  60. COM_INTERFACE_ENTRY(IOleControl)
  61. COM_INTERFACE_ENTRY(IOleObject)
  62. COM_INTERFACE_ENTRY(IPersistStreamInit)
  63. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  64. COM_INTERFACE_ENTRY_IMPL_IID(IID_IPersist, IPersistPropertyBag)
  65. COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag)
  66. COM_INTERFACE_ENTRY(IProvideClassInfo)
  67. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  68. COM_INTERFACE_ENTRY(IObjectSafety)
  69. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  70. #ifdef _WMP
  71. COM_INTERFACE_ENTRY(IWMPUIPlugin)
  72. COM_INTERFACE_ENTRY(IWMPUIPlugin2)
  73. COM_INTERFACE_ENTRY(IWMPUIPluginEvents)
  74. #endif
  75. END_COM_MAP()
  76. BEGIN_CONNECTION_POINT_MAP(CMSMFBBtn)
  77. CONNECTION_POINT_ENTRY(DIID__IMSMFBBtn)
  78. END_CONNECTION_POINT_MAP()
  79. BEGIN_PROP_MAP(CMSMFBBtn)
  80. // the properties are loaded in order below
  81. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  82. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  83. // Example entries
  84. // PROP_ENTRY("Property Description", dispid, clsid)
  85. // PROP_PAGE(CLSID_StockColorPage)
  86. PROP_ENTRY("TransparentBlitType", 4, CLSID_NULL)
  87. PROP_ENTRY("ResourceDLL", 12, CLSID_NULL)
  88. PROP_ENTRY("ImageStatic",1, CLSID_NULL)
  89. PROP_ENTRY("ImageHover", 2, CLSID_NULL)
  90. PROP_ENTRY("ImagePush", 3, CLSID_NULL)
  91. PROP_ENTRY("ImageDisabled", 14, CLSID_NULL)
  92. PROP_ENTRY("ImageActive", 15, CLSID_NULL)
  93. PROP_ENTRY("ToolTip", 9, CLSID_NULL)
  94. PROP_ENTRY("ToolTipMaxWidth", 13, CLSID_NULL)
  95. PROP_ENTRY("Windowless", 20, CLSID_NULL)
  96. PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
  97. END_PROPERTY_MAP()
  98. BEGIN_MSG_MAP(CMSMFBBtn)
  99. MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseToolTip)
  100. MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
  101. MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
  102. MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
  103. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  104. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  105. MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
  106. MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
  107. MESSAGE_HANDLER(WM_SIZE, OnSize)
  108. CHAIN_MSG_MAP(CMSMFCntrlUtils<CMSMFBBtn>)
  109. CHAIN_MSG_MAP(CComControl<CMSMFBBtn>)
  110. DEFAULT_REFLECTION_HANDLER()
  111. END_MSG_MAP()
  112. // Handler prototypes:
  113. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  114. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  115. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  116. LRESULT OnButtonDown(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  117. LRESULT OnButtonUp(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  118. LRESULT OnMouseMove(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  119. LRESULT OnMouseToolTip(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  120. LRESULT OnSetFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  121. LRESULT OnKillFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  122. LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  123. LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  124. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  125. // IViewObjectEx
  126. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  127. // IMSMFBBtn
  128. public:
  129. STDMETHOD(get_TextHeight)(/*[out, retval]*/ long *pVal);
  130. STDMETHOD(get_TextWidth)(/*[out, retval]*/ long *pVal);
  131. STDMETHOD(get_ColorActive)(/*[out, retval]*/ OLE_COLOR *pVal);
  132. STDMETHOD(put_ColorActive)(/*[in]*/ OLE_COLOR newVal);
  133. STDMETHOD(get_ColorDisable)(/*[out, retval]*/ OLE_COLOR *pVal);
  134. STDMETHOD(put_ColorDisable)(/*[in]*/ OLE_COLOR newVal);
  135. STDMETHOD(get_ColorStatic)(/*[out, retval]*/ OLE_COLOR *pVal);
  136. STDMETHOD(put_ColorStatic)(/*[in]*/ OLE_COLOR newVal);
  137. STDMETHOD(get_ColorHover)(/*[out, retval]*/ OLE_COLOR *pVal);
  138. STDMETHOD(put_ColorHover)(/*[in]*/ OLE_COLOR newVal);
  139. STDMETHOD(get_ColorPush)(/*[out, retval]*/ OLE_COLOR *pVal);
  140. STDMETHOD(put_ColorPush)(/*[in]*/ OLE_COLOR newVal);
  141. STDMETHOD(get_ImagePush)(/*[out, retval]*/ BSTR *pstrFilename);
  142. STDMETHOD(put_ImagePush)(/*[in]*/ BSTR strFilename);
  143. STDMETHOD(get_ImageHover)(/*[out, retval]*/ BSTR *pstrFilename);
  144. STDMETHOD(put_ImageHover)(/*[in]*/ BSTR strFilename);
  145. STDMETHOD(get_ImageStatic)(/*[out, retval]*/ BSTR *pstrFilename);
  146. STDMETHOD(put_ImageStatic)(/*[in]*/ BSTR strFilename);
  147. STDMETHOD(get_Disable)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  148. STDMETHOD(put_Disable)(/*[in]*/ VARIANT_BOOL newVal);
  149. STDMETHOD(get_BtnState)(/*[out, retval]*/ long *pVal);
  150. STDMETHOD(put_BtnState)(/*[in]*/ long newVal);
  151. STDMETHOD(get_ToolTip)(/*[out, retval]*/ BSTR *pVal);
  152. STDMETHOD(put_ToolTip)(/*[in]*/ BSTR newVal);
  153. USE_MF_RESOURCEDLL // replaces the two lines below
  154. //STDMETHOD(get_ResourceDLL)(/*[out, retval]*/ BSTR *pVal);
  155. //STDMETHOD(put_ResourceDLL)(/*[in]*/ BSTR newVal);
  156. STDMETHOD(GetDelayTime)(/*[in]*/ long delayType, /*[out, retval]*/ long *pVal);
  157. STDMETHOD(SetDelayTime)(/*[in]*/ long delayType, /*[in]*/ long newVal);
  158. STDMETHOD(get_ImageActive)(/*[out, retval]*/ BSTR *pVal);
  159. STDMETHOD(put_ImageActive)(/*[in]*/ BSTR newVal);
  160. STDMETHOD(get_ImageDisabled)(/*[out, retval]*/ BSTR *pVal);
  161. STDMETHOD(put_ImageDisabled)(/*[in]*/ BSTR newVal);
  162. STDMETHOD(get_ToolTipMaxWidth)(/*[out, retval]*/ long *pVal);
  163. STDMETHOD(put_ToolTipMaxWidth)(/*[in]*/ long newVal);
  164. STDMETHOD(get_FontStyle)(/*[out, retval]*/ BSTR *pVal);
  165. STDMETHOD(put_FontStyle)(/*[in]*/ BSTR newVal);
  166. STDMETHOD(get_FontFace)(/*[out, retval]*/ BSTR *pVal);
  167. STDMETHOD(put_FontFace)(/*[in]*/ BSTR newVal);
  168. STDMETHOD(get_Text)(/*[out, retval]*/ BSTR *pVal);
  169. STDMETHOD(put_Text)(/*[in]*/ BSTR newVal);
  170. STDMETHOD(get_FontSize)(/*[out, retval]*/ long *pVal);
  171. STDMETHOD(put_FontSize)(/*[in]*/ long newVal);
  172. STDMETHOD(About)();
  173. USE_MF_WINDOWLESS_ACTIVATION // replaces the two lines below
  174. //STDMETHOD(get_Windowless)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  175. //STDMETHOD(put_Windowless)(/*[in]*/ VARIANT_BOOL newVal);
  176. USE_MF_TRANSPARENT_FLAG
  177. HRESULT OnDraw(ATL_DRAWINFO& di);
  178. // IOleInPlaceObjectWindowlessImpl
  179. STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip);
  180. // IOleObjectImp
  181. HRESULT OnPostVerbInPlaceActivate();
  182. public:
  183. enum BtnState {Static = 0, Hover = 1, Push = 2, Disabled = 3, Active = 4};
  184. USE_MF_OVERWRITES
  185. USE_MF_CLASSSTYLE // used to overwrite default class, so we avoid flickers
  186. public: // member variable that have to be public due to ATL
  187. OLE_COLOR m_clrBackColor; // stock property implemeted in the CStockPropImpl
  188. private: // data member variables
  189. CComBSTR m_bstrFilename[cgMaxBtnStates]; // filenames containing the images
  190. CBitmap* m_pBitmap[cgMaxBtnStates];
  191. BtnState m_nEntry;
  192. HWND m_hWndTip; // Tooltip window
  193. LONG m_nTTMaxWidth; // Max tooltip width
  194. CComBSTR m_bstrToolTip; // Tooltip string
  195. BOOL m_bTTCreated; // Has tooltip been created yet
  196. CText m_cText; // text drawing object
  197. bool m_fDirty; // if any attribute for the text drawing object changes
  198. CComBSTR m_bstrTextValue;
  199. CComBSTR m_bstrFontFace;
  200. CComBSTR m_bstrFontStyle;
  201. UINT m_uiFontSize;
  202. OLE_COLOR m_clrColorActive;
  203. OLE_COLOR m_clrColorStatic;
  204. OLE_COLOR m_clrColorHover;
  205. OLE_COLOR m_clrColorPush;
  206. OLE_COLOR m_clrColorDisable;
  207. protected: // helper functions
  208. void Init();
  209. bool PtOnButton(LONG x, LONG y);
  210. bool PtOnButton(POINT pos);
  211. HRESULT CreateToolTip(void);
  212. HRESULT PutImage(BSTR strFilename, int nEntry);
  213. HRESULT SetButtonState(BtnState btnState);
  214. HRESULT SetTextProperties();
  215. };
  216. #endif //__MSMFBBTN_H_
  217. /*************************************************************************/
  218. /* End of file: MSMFBBtn.h */
  219. /*************************************************************************/