Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cOleWebHelper.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cOleWebHelper_H
6 #define _INC_cOleWebHelper_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 #include "cOleControl.h"
11 
12 #if defined(_WIN32) && defined(_MSC_VER)
13 #include "cOleWebBase.h"
14 #include "../WinAPI/cComConnectionPoint.h"
15 
16 #include <exdisp.h> // DWebBrowserEvents2, IWebBrowser2
17 #include <exdispid.h>
18 #include <mshtmlc.h>
19 #include <shobjidl.h> // NWMF_USERINITED
20 
21 namespace GrayLib
22 {
23  class cOleWebBase;
24 
25  class GRAYLIB_LINK cOleWebHelper : public cComConnectionPoint, public DWebBrowserEvents2
26  {
30 
31  typedef cComConnectionPoint SUPER_t;
32 
33  protected:
34  cTimeSys m_tProgressChange;
35  cOleWebBase* m_pOleControlParent;
36 
37  protected:
38  // IDispatch method
39  static cStringA GetFileNameDecode(cStringA sName);
40 
41  HRESULT SendWebEvent(IOleWebListener::WEBEVENT_TYPE eEvent, BSTR theParam, int x = 0, int y = 0);
42 
43  virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
44  WORD wFlags, ::DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult,
45  ::EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr);
46 
47  public:
48  cOleWebHelper(cOleWebBase* pAtlControlParent)
49  : cComConnectionPoint(static_cast<DWebBrowserEvents2*>(this), LIBID_SHDocVw, __uuidof(DWebBrowserEvents2))
50  , m_pOleControlParent(pAtlControlParent)
51  {
52  ASSERT(m_pOleControlParent != nullptr);
53  ASSERT(m_pOleControlParent->m_pWebBrowser != nullptr);
54  ASSERT(!isDisposed());
55  }
56 
57  virtual ~cOleWebHelper()
58  {
59  }
60 
61  IUNKNOWN_DISAMBIG_R(cRefBase);
62  IDISPATCH_DISAMBIG_R(cComDispatch);
63 
64  virtual bool isDisposed() const
65  {
66  return m_pOleControlParent == nullptr;
67  }
68  virtual HRESULT DisposeThis()
69  {
70  m_pOleControlParent = nullptr;
71  HRESULT hRes = SUPER_t::DisposeThis();
72  return hRes;
73  }
74 
75  STDMETHOD(QueryInterface)(REFIID riid, LPVOID* ppv)
76  {
77  if (riid == __uuidof(DWebBrowserEvents2))
78  {
79  *ppv = static_cast<DWebBrowserEvents2*>(this);
80  }
81  else
82  {
83  return SUPER_t::QueryInterface(riid, ppv);
84  }
85  AddRef();
86  return S_OK;
87  }
88  };
89 }
90 
91 #endif
92 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define IUNKNOWN_DISAMBIG_R(TYPE)
Definition: IUnknown.h:85
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cMesh.h:22
cStringT< char > cStringA
Definition: cString.h:635