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.

238 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 CStockPropImpl<CMSMFBBtn, IMSMFBBtn, &IID_IMSMFBBtn, &LIBID_MSMFCNTLib>,
  25. public CComControl<CMSMFBBtn>,
  26. public IPersistStreamInitImpl<CMSMFBBtn>,
  27. public IOleControlImpl<CMSMFBBtn>,
  28. public IOleObjectImpl<CMSMFBBtn>,
  29. public IOleInPlaceActiveObjectImpl<CMSMFBBtn>,
  30. public IViewObjectExImpl<CMSMFBBtn>,
  31. public IOleInPlaceObjectWindowlessImpl<CMSMFBBtn>,
  32. public IPersistPropertyBagImpl<CMSMFBBtn>,
  33. public CComCoClass<CMSMFBBtn, &CLSID_MSMFBBtn>,
  34. public IProvideClassInfo2Impl<&CLSID_MSMFBBtn, &DIID__IMSMFBBtn, &LIBID_MSMFCNTLib>,
  35. public IObjectSafetyImpl<CMSMFBBtn, INTERFACESAFE_FOR_UNTRUSTED_CALLER| INTERFACESAFE_FOR_UNTRUSTED_DATA>,
  36. #ifdef _WMP
  37. public IWMPUIPluginImpl<CMSMFBBtn>,
  38. public IWMPUIPluginEventsImpl,
  39. #endif
  40. public IConnectionPointContainerImpl<CMSMFBBtn>,
  41. public CProxy_IMSMFBBtn< CMSMFBBtn >,
  42. public CMSMFCntrlUtils<CMSMFBBtn> // custom utilities we share across controls
  43. {
  44. public:
  45. CMSMFBBtn();
  46. virtual ~CMSMFBBtn();
  47. DECLARE_REGISTRY_RESOURCEID(IDR_MSMFBBTN)
  48. DECLARE_PROTECT_FINAL_CONSTRUCT()
  49. BEGIN_COM_MAP(CMSMFBBtn)
  50. COM_INTERFACE_ENTRY(IMSMFBBtn)
  51. COM_INTERFACE_ENTRY(IDispatch)
  52. COM_INTERFACE_ENTRY(IViewObjectEx)
  53. COM_INTERFACE_ENTRY(IViewObject2)
  54. COM_INTERFACE_ENTRY(IViewObject)
  55. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  56. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  57. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  58. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  59. COM_INTERFACE_ENTRY(IOleControl)
  60. COM_INTERFACE_ENTRY(IOleObject)
  61. COM_INTERFACE_ENTRY(IPersistStreamInit)
  62. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  63. COM_INTERFACE_ENTRY_IMPL_IID(IID_IPersist, IPersistPropertyBag)
  64. COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag)
  65. COM_INTERFACE_ENTRY(IProvideClassInfo)
  66. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  67. COM_INTERFACE_ENTRY(IObjectSafety)
  68. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  69. #ifdef _WMP
  70. COM_INTERFACE_ENTRY(IWMPUIPlugin)
  71. COM_INTERFACE_ENTRY(IWMPUIPlugin2)
  72. COM_INTERFACE_ENTRY(IWMPUIPluginEvents)
  73. #endif
  74. END_COM_MAP()
  75. BEGIN_CONNECTION_POINT_MAP(CMSMFBBtn)
  76. CONNECTION_POINT_ENTRY(DIID__IMSMFBBtn)
  77. END_CONNECTION_POINT_MAP()
  78. BEGIN_PROP_MAP(CMSMFBBtn)
  79. // the properties are loaded in order below
  80. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  81. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  82. // Example entries
  83. // PROP_ENTRY("Property Description", dispid, clsid)
  84. // PROP_PAGE(CLSID_StockColorPage)
  85. PROP_ENTRY("TransparentBlitType", 4, CLSID_NULL)
  86. PROP_ENTRY("ResourceDLL", 13, CLSID_NULL)
  87. PROP_ENTRY("ImageStatic",1, CLSID_NULL)
  88. PROP_ENTRY("ImageHover", 2, CLSID_NULL)
  89. PROP_ENTRY("ImagePush", 3, CLSID_NULL)
  90. PROP_ENTRY("ImageDisabled", 14, CLSID_NULL)
  91. PROP_ENTRY("ImageActive", 15, CLSID_NULL)
  92. PROP_ENTRY("ToolTip", 9, CLSID_NULL)
  93. PROP_ENTRY("ToolTipMaxWidth", 12, CLSID_NULL)
  94. PROP_ENTRY("Windowless", 20, CLSID_NULL)
  95. PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
  96. END_PROPERTY_MAP()
  97. BEGIN_MSG_MAP(CMSMFBBtn)
  98. CHAIN_MSG_MAP(CMSMFCntrlUtils<CMSMFBBtn>)
  99. MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
  100. MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
  101. MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
  102. MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnDblClick)
  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. MESSAGE_HANDLER(WM_DISPLAYCHANGE, OnDispChange)
  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 OnDblClick(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  119. LRESULT OnMouseMove(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. LRESULT OnDispChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  126. // IViewObjectEx
  127. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  128. // IMSMFBBtn
  129. public:
  130. STDMETHOD(get_TextHeight)(/*[out, retval]*/ long *pVal);
  131. STDMETHOD(get_TextWidth)(/*[out, retval]*/ long *pVal);
  132. STDMETHOD(get_ColorActive)(/*[out, retval]*/ OLE_COLOR *pVal);
  133. STDMETHOD(put_ColorActive)(/*[in]*/ OLE_COLOR newVal);
  134. STDMETHOD(get_ColorDisable)(/*[out, retval]*/ OLE_COLOR *pVal);
  135. STDMETHOD(put_ColorDisable)(/*[in]*/ OLE_COLOR newVal);
  136. STDMETHOD(get_ColorStatic)(/*[out, retval]*/ OLE_COLOR *pVal);
  137. STDMETHOD(put_ColorStatic)(/*[in]*/ OLE_COLOR newVal);
  138. STDMETHOD(get_ColorHover)(/*[out, retval]*/ OLE_COLOR *pVal);
  139. STDMETHOD(put_ColorHover)(/*[in]*/ OLE_COLOR newVal);
  140. STDMETHOD(get_ColorPush)(/*[out, retval]*/ OLE_COLOR *pVal);
  141. STDMETHOD(put_ColorPush)(/*[in]*/ OLE_COLOR newVal);
  142. STDMETHOD(get_ImagePush)(/*[out, retval]*/ BSTR *pstrFilename);
  143. STDMETHOD(put_ImagePush)(/*[in]*/ BSTR strFilename);
  144. STDMETHOD(get_ImageHover)(/*[out, retval]*/ BSTR *pstrFilename);
  145. STDMETHOD(put_ImageHover)(/*[in]*/ BSTR strFilename);
  146. STDMETHOD(get_ImageStatic)(/*[out, retval]*/ BSTR *pstrFilename);
  147. STDMETHOD(put_ImageStatic)(/*[in]*/ BSTR strFilename);
  148. STDMETHOD(get_Disable)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  149. STDMETHOD(put_Disable)(/*[in]*/ VARIANT_BOOL newVal);
  150. STDMETHOD(get_BtnState)(/*[out, retval]*/ long *pVal);
  151. STDMETHOD(put_BtnState)(/*[in]*/ long newVal);
  152. USE_MF_RESOURCEDLL // replaces the two lines below
  153. //STDMETHOD(get_ResourceDLL)(/*[out, retval]*/ BSTR *pVal);
  154. //STDMETHOD(put_ResourceDLL)(/*[in]*/ BSTR newVal);
  155. USE_MF_TOOLTIP
  156. //STDMETHOD(GetDelayTime)(/*[in]*/ long delayType, /*[out, retval]*/ long *pVal);
  157. //STDMETHOD(SetDelayTime)(/*[in]*/ long delayType, /*[in]*/ long newVal);
  158. //STDMETHOD(get_ToolTip)(/*[out, retval]*/ BSTR *pVal);
  159. //STDMETHOD(put_ToolTip)(/*[in]*/ BSTR newVal);
  160. //STDMETHOD(get_ToolTipMaxWidth)(/*[out, retval]*/ long *pVal);
  161. //STDMETHOD(put_ToolTipMaxWidth)(/*[in]*/ long newVal);
  162. STDMETHOD(get_ImageActive)(/*[out, retval]*/ BSTR *pVal);
  163. STDMETHOD(put_ImageActive)(/*[in]*/ BSTR newVal);
  164. STDMETHOD(get_ImageDisabled)(/*[out, retval]*/ BSTR *pVal);
  165. STDMETHOD(put_ImageDisabled)(/*[in]*/ BSTR newVal);
  166. STDMETHOD(get_FontStyle)(/*[out, retval]*/ BSTR *pVal);
  167. STDMETHOD(put_FontStyle)(/*[in]*/ BSTR newVal);
  168. STDMETHOD(get_FontFace)(/*[out, retval]*/ BSTR *pVal);
  169. STDMETHOD(put_FontFace)(/*[in]*/ BSTR newVal);
  170. STDMETHOD(get_Text)(/*[out, retval]*/ BSTR *pVal);
  171. STDMETHOD(put_Text)(/*[in]*/ BSTR newVal);
  172. STDMETHOD(get_FontSize)(/*[out, retval]*/ long *pVal);
  173. STDMETHOD(put_FontSize)(/*[in]*/ long newVal);
  174. STDMETHOD(About)();
  175. USE_MF_WINDOWLESS_ACTIVATION // replaces the two lines below
  176. //STDMETHOD(get_Windowless)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  177. //STDMETHOD(put_Windowless)(/*[in]*/ VARIANT_BOOL newVal);
  178. USE_MF_TRANSPARENT_FLAG
  179. HRESULT OnDraw(ATL_DRAWINFO& di);
  180. // IOleInPlaceObjectWindowlessImpl
  181. STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip);
  182. // IOleObjectImp
  183. //HRESULT OnPostVerbInPlaceActivate();
  184. public:
  185. enum BtnState {Static = 0, Hover = 1, Push = 2, Disabled = 3, Active = 4};
  186. USE_MF_OVERWRITES
  187. USE_MF_CLASSSTYLE // used to overwrite default class, so we avoid flickers
  188. public: // member variable that have to be public due to ATL
  189. OLE_COLOR m_clrBackColor; // stock property implemeted in the CStockPropImpl
  190. private: // data member variables
  191. CComBSTR m_bstrFilename[cgMaxBtnStates]; // filenames containing the images
  192. CBitmap* m_pBitmap[cgMaxBtnStates];
  193. BtnState m_nEntry;
  194. CText m_cText; // text drawing object
  195. bool m_fDirty; // if any attribute for the text drawing object changes
  196. CComBSTR m_bstrTextValue;
  197. CComBSTR m_bstrFontFace;
  198. CComBSTR m_bstrFontStyle;
  199. UINT m_uiFontSize;
  200. OLE_COLOR m_clrColorActive;
  201. OLE_COLOR m_clrColorStatic;
  202. OLE_COLOR m_clrColorHover;
  203. OLE_COLOR m_clrColorPush;
  204. OLE_COLOR m_clrColorDisable;
  205. DWORD m_dwButtonClickStamp;
  206. protected: // helper functions
  207. void Init();
  208. bool PtOnButton(LONG x, LONG y);
  209. bool PtOnButton(POINT pos);
  210. HRESULT PutImage(BSTR strFilename, int nEntry);
  211. HRESULT SetButtonState(BtnState btnState);
  212. HRESULT SetTextProperties();
  213. };
  214. #endif //__MSMFBBTN_H_
  215. /*************************************************************************/
  216. /* End of file: MSMFBBtn.h */
  217. /*************************************************************************/