ReactOS 0.4.15-dev-8419-g7f0e8a3
newatlinterfaces.h
Go to the documentation of this file.
1/*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#pragma once
22
23template<class T>
25{
26public:
28 {
29 return E_NOTIMPL;
30 }
31
33 {
34 return E_NOTIMPL;
35 }
36
38 {
39 return E_FAIL;
40 }
41};
42
43/*
44This subclass corrects a problem with the ATL IConnectionPointImpl.
45IConnectionPointImpl queries for the exact interface that is published, but at least one
46implementor of IConnectionPoint (CShellBrowser) advertises DIID_DWebBrowserEvents,
47but fires events to IDispatch.
48*/
49template<class T, const IID *piid, class CDV = CComDynamicUnkArray>
50class MyIConnectionPointImpl : public IConnectionPointImpl<T, piid, CDV>
51{
52public:
53 STDMETHODIMP Advise(IUnknown *pUnkSink, DWORD *pdwCookie)
54 {
55 IConnectionPointImpl<T, piid, CDV> *pThisCPImpl;
56 T *pThis;
57 IUnknown *adviseSink;
58 DWORD newCookie;
59 HRESULT hResult;
60
61 pThis = static_cast<T *>(this);
62 pThisCPImpl = static_cast<IConnectionPointImpl<T, piid, CDV> *>(this);
63 if (pdwCookie != NULL)
64 *pdwCookie = 0;
65 if (pUnkSink == NULL || pdwCookie == NULL)
66 return E_POINTER;
67 hResult = pUnkSink->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(&adviseSink));
68 if (FAILED(hResult))
69 {
70 if (hResult == E_NOINTERFACE)
72 return hResult;
73 }
74 pThis->Lock();
75 newCookie = pThisCPImpl->m_vec.Add(adviseSink);
76 pThis->Unlock();
77 *pdwCookie = newCookie;
78 if (newCookie != 0)
79 hResult = S_OK;
80 else
81 {
82 adviseSink->Release();
83 hResult = CONNECT_E_ADVISELIMIT;
84 }
85 return hResult;
86 }
87};
#define STDMETHODIMP
Definition: basetyps.h:43
STDMETHODIMP RevokeService(DWORD dwCookie)
STDMETHODIMP ProfferService(REFGUID rguidService, IServiceProvider *psp, DWORD *pdwCookie)
HRESULT QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
STDMETHODIMP Advise(IUnknown *pUnkSink, DWORD *pdwCookie)
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define T
Definition: mbstring.h:31
static REFIID
Definition: ordinal.c:54
#define CONNECT_E_CANNOTCONNECT
Definition: olectl.h:253
#define CONNECT_E_ADVISELIMIT
Definition: olectl.h:252
const GUID IID_IDispatch
Definition: scsiwmi.h:51
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365