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.

195 lines
6.6 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Behaviors.h
  5. Abstract:
  6. This file contains the declaration of various classes associated with
  7. binary behaviors.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 06/06/2000
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___PCH___BEHAVIORS_H___)
  13. #define __INCLUDED___PCH___BEHAVIORS_H___
  14. #include <mshtmlc.h>
  15. class CPCHHelpCenterExternal;
  16. /////////////////////////////////////////////////////////////////////////////
  17. /////////////////////////////////////////////////////////////////////////////
  18. class ATL_NO_VTABLE CPCHElementBehaviorFactory : // Hungarian: hcebf
  19. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  20. public IServiceProvider,
  21. public IElementBehaviorFactory
  22. {
  23. CPCHHelpCenterExternal* m_parent;
  24. public:
  25. BEGIN_COM_MAP(CPCHElementBehaviorFactory)
  26. COM_INTERFACE_ENTRY(IServiceProvider)
  27. COM_INTERFACE_ENTRY(IElementBehaviorFactory)
  28. END_COM_MAP()
  29. CPCHElementBehaviorFactory();
  30. void Initialize( /*[in]*/ CPCHHelpCenterExternal* parent );
  31. //////////////////////////////////////////////////////////////////////
  32. //
  33. // IServiceProvider
  34. //
  35. STDMETHOD(QueryService)( REFGUID guidService, REFIID riid, void **ppv );
  36. //
  37. // IElementBehaviorFactory
  38. //
  39. STDMETHOD(FindBehavior)( /*[in]*/ BSTR bstrBehavior ,
  40. /*[in]*/ BSTR bstrBehaviorUrl ,
  41. /*[in]*/ IElementBehaviorSite* pSite ,
  42. /*[out]*/ IElementBehavior* *ppBehavior );
  43. };
  44. /////////////////////////////////////////////////////////////////////////////
  45. class ATL_NO_VTABLE CPCHBehavior :
  46. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  47. public IElementBehavior
  48. {
  49. public:
  50. struct EventDescription
  51. {
  52. LPCWSTR szName;
  53. DISPID id;
  54. };
  55. protected:
  56. typedef HRESULT (CPCHBehavior::*CLASS_METHOD)( DISPID, DISPPARAMS*, VARIANT* );
  57. struct EventSink : public IDispatch
  58. {
  59. long m_lRef;
  60. CPCHBehavior* m_Parent;
  61. CComPtr<IDispatch> m_elem;
  62. CComBSTR m_bstrName;
  63. CLASS_METHOD m_pfn;
  64. bool m_fAttached;
  65. DISPID m_idNotifyAs;
  66. EventSink( CPCHBehavior* parent );
  67. ~EventSink();
  68. HRESULT Attach();
  69. HRESULT Detach();
  70. //
  71. // IUnknown
  72. //
  73. STDMETHOD_(ULONG, AddRef)();
  74. STDMETHOD_(ULONG, Release)();
  75. STDMETHOD(QueryInterface)( REFIID iid, void ** ppvObject );
  76. //
  77. // IDispatch
  78. //
  79. STDMETHOD(GetTypeInfoCount)( UINT* pctinfo );
  80. STDMETHOD(GetTypeInfo)( UINT itinfo ,
  81. LCID lcid ,
  82. ITypeInfo* *pptinfo );
  83. STDMETHOD(GetIDsOfNames)( REFIID riid ,
  84. LPOLESTR* rgszNames ,
  85. UINT cNames ,
  86. LCID lcid ,
  87. DISPID* rgdispid );
  88. STDMETHOD(Invoke)( DISPID dispidMember ,
  89. REFIID riid ,
  90. LCID lcid ,
  91. WORD wFlags ,
  92. DISPPARAMS* pdispparams ,
  93. VARIANT* pvarResult ,
  94. EXCEPINFO* pexcepinfo ,
  95. UINT* puArgErr );
  96. static HRESULT CreateInstance( /*[in]*/ CPCHBehavior* parent, /*[out]*/ EventSink*& pObj );
  97. };
  98. typedef std::list< EventSink* > SinkList;
  99. typedef SinkList::iterator SinkIter;
  100. typedef SinkList::const_iterator SinkIterConst;
  101. ////////////////////////////////////////
  102. CPCHHelpCenterExternal* m_parent;
  103. CComPtr<IElementBehaviorSiteOM> m_siteOM;
  104. CComPtr<IHTMLElement> m_elem;
  105. CComPtr<IHTMLElement2> m_elem2;
  106. SinkList m_lstEventSinks;
  107. bool m_fRTL;
  108. bool m_fTrusted;
  109. bool m_fSystem;
  110. ////////////////////////////////////////
  111. HRESULT AttachToEvent( /*[in] */ LPCWSTR szName ,
  112. /*[in] */ CLASS_METHOD pfn ,
  113. /*[in] */ IDispatch* elem = NULL ,
  114. /*[out]*/ IDispatch* *pVal = NULL ,
  115. /*[in] */ DISPID id = -1 );
  116. HRESULT AttachToEvents( /*[in] */ const EventDescription* pEvents ,
  117. /*[in] */ CLASS_METHOD pfn ,
  118. /*[in] */ IDispatch* elem = NULL );
  119. HRESULT CreateEvent ( /*[in]*/ LPCWSTR szName, /*[out]*/ LONG& lEventCookie );
  120. HRESULT GetEventObject ( /*[out]*/ CComPtr<IHTMLEventObj>& ev );
  121. HRESULT CreateEventObject( /*[out]*/ CComPtr<IHTMLEventObj>& ev );
  122. HRESULT FireEvent ( /*[in ]*/ IHTMLEventObj* ev, /*[in]*/ LONG lEventCookie );
  123. HRESULT FireEvent ( /*[in]*/ LONG lEventCookie );
  124. HRESULT CancelEvent( /*[in]*/ IHTMLEventObj* ev = NULL, /*[in]*/ VARIANT* pvReturnValue = NULL, /*[in]*/ VARIANT_BOOL fCancelBubble = VARIANT_TRUE );
  125. ////////////////////////////////////////
  126. HRESULT GetEvent_SrcElement( /*[in]*/ CComPtr<IHTMLElement>& elem );
  127. ////////////////////////////////////////
  128. HRESULT GetAsVARIANT ( /*[in]*/ BSTR value, /*[out, retval]*/ VARIANT *pVal );
  129. HRESULT GetAsVARIANT ( /*[in]*/ IDispatch* value, /*[out, retval]*/ VARIANT *pVal );
  130. HRESULT GetAsIDISPATCH( /*[in]*/ IDispatch* value, /*[out, retval]*/ IDispatch* *pVal );
  131. ////////////////////////////////////////
  132. public:
  133. BEGIN_COM_MAP(CPCHBehavior)
  134. COM_INTERFACE_ENTRY(IElementBehavior)
  135. END_COM_MAP()
  136. CPCHBehavior();
  137. void Initialize( /*[in]*/ CPCHHelpCenterExternal* parent );
  138. //
  139. // IElementBehavior
  140. //
  141. STDMETHOD(Init )( /*[in]*/ IElementBehaviorSite* pBehaviorSite );
  142. STDMETHOD(Notify)( /*[in]*/ LONG lEvent, /*[in/out]*/ VARIANT* pVar );
  143. STDMETHOD(Detach)( );
  144. };
  145. /////////////////////////////////////////////////////////////////////////////
  146. #endif // !defined(__INCLUDED___PCH___BEHAVIORS_H___)