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.

292 lines
6.8 KiB

  1. //************************************************************
  2. //
  3. // Copyright (C) Microsoft Corporation, 1999
  4. //
  5. // FileName: wmp.h
  6. //
  7. // Description: Modified template for wmp pluging
  8. //************************************************************
  9. #ifndef _WMPPLUGINIMPL_H_
  10. #define _WMPPLUGINIMPL_H_
  11. #pragma once
  12. //#include "wmputil.h"
  13. #include "c:\wmp\private\wmp\dev\idl\plugin.h"
  14. //#include "c:\wmp\private\wmp\dev\include\wmpcore.h"
  15. //#include "color.h"
  16. #include "c:\wmp\private\wmp\dev\include\dynarray.h"
  17. #include "atlbase.h"
  18. // Example usage:
  19. // class CMyNodeActiveX :
  20. // public IWMPUIPluginImpl<CMyNodeActiveX>
  21. // {
  22. // DECLARE_WMP_NODE( IWMPSpectrumAnalyzer )
  23. // }
  24. //
  25. #define DECLARE_WMP_NODE( NODE ) \
  26. CComPtr<NODE> m_spNode; \
  27. STDMETHODIMP GetPrimaryIID( IID * pMainIID ) \
  28. { \
  29. E_POINTER_RETURN( pMainIID ); \
  30. *pMainIID = IID_##NODE; \
  31. return S_OK; \
  32. } \
  33. STDMETHODIMP ConnectNode( IUnknown * pBaseNode ) \
  34. { \
  35. E_POINTER_RETURN( pBaseNode ); \
  36. HRESULT hr = pBaseNode->QueryInterface( IID_##NODE, reinterpret_cast<LPVOID *>(&m_spNode) ); \
  37. if (SUCCEEDED(hr)) \
  38. { \
  39. hr = OnConnectNode(); \
  40. if (FAILED(hr)) \
  41. { \
  42. DPF( 3, A, "OnConnectNode() Failed (%s)", #NODE ); \
  43. m_spNode.Release(); \
  44. } \
  45. } \
  46. else \
  47. { \
  48. DPF( 3, A, "The node given to this ActiveX control failed a QI for: %s", #NODE ); \
  49. } \
  50. return hr; \
  51. } \
  52. STDMETHODIMP DisconnectNode() \
  53. { \
  54. HRESULT hr = OnDisconnectNode(); \
  55. if (FAILED(hr)) \
  56. { \
  57. DPF( 3, A, "OnDisconnectNode() Failure: %s", #NODE ); \
  58. } \
  59. m_spNode.Release(); \
  60. return hr; \
  61. } \
  62. //************************************************************
  63. class ATL_NO_VTABLE IWMPUIPluginEventsImpl :
  64. public IWMPUIPluginEvents
  65. {
  66. public:
  67. #ifdef DEBUG
  68. ~IWMPUIPluginEventsImpl(){};
  69. #endif
  70. // IWMPUIPluginEvents
  71. STDMETHOD(FireStateChange)( DISPID dispid ){return E_NOTIMPL;};
  72. STDMETHOD(WMPAdvise)( IUnknown * pUnknown, DWORD * pdwCookie ){return E_NOTIMPL;};
  73. STDMETHOD(WMPUnadvise)( DWORD dwCookie ){return E_NOTIMPL;};
  74. // Helper functions for the derriving object
  75. void DoNotify( int nType, DISPID dspidProperty, const VARIANT varParam );
  76. void DoPropertyChange( DISPID dispid );
  77. void DoStateChange( DISPID dispid, bool fEnabled );
  78. void DoRegionChange();
  79. protected:
  80. DynamicArray<IWMPUIPluginNotify *> m_EventSites;
  81. };
  82. //************************************************************
  83. template <class T>
  84. class ATL_NO_VTABLE IWMPUIPluginImpl :
  85. public IWMPUIPlugin2
  86. {
  87. public:
  88. IWMPUIPluginImpl();
  89. STDMETHOD(OnConnectNode)();
  90. STDMETHOD(OnDisconnectNode)();
  91. STDMETHOD(SetTransparencyColor)( WCHAR * pwszColor );
  92. STDMETHOD(GetTransparencyColor)( BSTR * pbstrColor );
  93. // IWMPUIPlugin
  94. STDMETHOD(SetCore)(IUnknown *pMediaPlayer);
  95. STDMETHOD(GetPrimaryIID)(IID *pMainIID);
  96. STDMETHOD(ConnectNode)(IUnknown *pBaseNode);
  97. STDMETHOD(DisconnectNode)();
  98. // IWMPUIPlugin2
  99. STDMETHOD(CreateInstance)( BSTR bstrObjectType, IDispatch ** ppDispatch );
  100. STDMETHOD(GetTransparencyColor)( OLE_COLOR * pColor );
  101. protected:
  102. //CComPtr<IWMPCore> m_spCore;
  103. COLORREF m_crTransparent;
  104. bool m_fTransparent;
  105. };
  106. //************************************************************
  107. // IWMPUIPluginImpl
  108. //************************************************************
  109. template <class T>
  110. IWMPUIPluginImpl<T>::IWMPUIPluginImpl() :
  111. m_crTransparent(0x00000000),
  112. m_fTransparent(false)
  113. {
  114. }
  115. //************************************************************
  116. template <class T>
  117. STDMETHODIMP IWMPUIPluginImpl<T>::OnConnectNode()
  118. {
  119. return S_OK;
  120. }
  121. //************************************************************
  122. template <class T>
  123. STDMETHODIMP IWMPUIPluginImpl<T>::OnDisconnectNode()
  124. {
  125. return S_OK;
  126. }
  127. //************************************************************
  128. template <class T>
  129. STDMETHODIMP IWMPUIPluginImpl<T>::SetTransparencyColor( WCHAR * pwszColor )
  130. {
  131. #if 1
  132. return E_NOTIMPL;
  133. #else
  134. E_POINTER_RETURN( pwszColor );
  135. bool fTransparent = m_fTransparent;
  136. COLORREF crTransparent = m_crTransparent;
  137. HRESULT hr = StringToColor( pwszColor, &m_crTransparent, &m_fTransparent );
  138. DPF_HR( hr, L, "StringToColor" );
  139. if (SUCCEEDED(hr))
  140. {
  141. m_fTransparent = !m_fTransparent;
  142. }
  143. if (SUCCEEDED(hr) && ((fTransparent != m_fTransparent) || (crTransparent != m_crTransparent)))
  144. {
  145. T* pT = static_cast<T*>(this);
  146. hr = pT->FireViewChange();
  147. DPF_HR( hr, L, "pT->FireViewChange" );
  148. }
  149. return hr;
  150. #endif
  151. }
  152. //************************************************************
  153. template <class T>
  154. STDMETHODIMP IWMPUIPluginImpl<T>::GetTransparencyColor( BSTR * pbstrColor )
  155. {
  156. #if 1
  157. return E_NOTIMPL;
  158. #else
  159. WString wsz;
  160. WCHAR * pwsz = wsz;
  161. HRESULT hr = ColorToString( &pwsz, m_crTransparent, m_fTransparent );
  162. DPF_HR( hr, L, "ColorToString" );
  163. if (SUCCEEDED(hr))
  164. {
  165. m_fTransparent = !m_fTransparent;
  166. *pbstrColor = wsz.CopyToBSTR();
  167. HRMEMCHECK( hr, *pbstrColor );
  168. }
  169. return hr;
  170. #endif
  171. }
  172. //************************************************************
  173. // IWMPUIPlugin
  174. //************************************************************
  175. template <class T>
  176. STDMETHODIMP IWMPUIPluginImpl<T>::SetCore( IUnknown * pMediaPlayer )
  177. {
  178. #if 1
  179. return E_NOTIMPL;
  180. #else
  181. m_spCore.Release();
  182. if (pMediaPlayer)
  183. {
  184. return pMediaPlayer->QueryInterface( IID_IWMPCore, reinterpret_cast<LPVOID *>(&m_spCore) );
  185. }
  186. return S_OK;
  187. #endif
  188. }
  189. //************************************************************
  190. template <class T>
  191. STDMETHODIMP IWMPUIPluginImpl<T>::GetPrimaryIID( IID * pMainIID )
  192. {
  193. return E_NOTIMPL;
  194. }
  195. //************************************************************
  196. template <class T>
  197. STDMETHODIMP IWMPUIPluginImpl<T>::ConnectNode( IUnknown * pBaseNode )
  198. {
  199. return E_NOTIMPL;
  200. }
  201. //************************************************************
  202. template <class T>
  203. STDMETHODIMP IWMPUIPluginImpl<T>::DisconnectNode()
  204. {
  205. return E_NOTIMPL;
  206. }
  207. //************************************************************
  208. template <class T>
  209. STDMETHODIMP IWMPUIPluginImpl<T>::CreateInstance( BSTR bstrObjectType, IDispatch ** ppDispatch )
  210. {
  211. // E_POINTER_RETURN( bstrObjectType );
  212. // E_POINTER_RETURN( ppDispatch );
  213. return E_NOTIMPL;
  214. }
  215. //************************************************************
  216. template <class T>
  217. STDMETHODIMP IWMPUIPluginImpl<T>::GetTransparencyColor( OLE_COLOR * pColor )
  218. {
  219. *pColor = static_cast<OLE_COLOR>(m_crTransparent);
  220. return S_OK;
  221. }
  222. //************************************************************
  223. #endif // _WMPPLUGINIMPL_H_