[SHELLFIND] Remove unnecessary data member for focus
[reactos.git] / dll / win32 / browseui / newatlinterfaces.h
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
23 template<class T>
24 class IProfferServiceImpl : public IProfferService
25 {
26 public:
27 STDMETHODIMP ProfferService(REFGUID rguidService, IServiceProvider *psp, DWORD *pdwCookie)
28 {
29 return E_NOTIMPL;
30 }
31
32 STDMETHODIMP RevokeService(DWORD dwCookie)
33 {
34 return E_NOTIMPL;
35 }
36
37 HRESULT QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
38 {
39 return E_FAIL;
40 }
41 };
42
43 /*
44 This subclass corrects a problem with the ATL IConnectionPointImpl.
45 IConnectionPointImpl queries for the exact interface that is published, but at least one
46 implementor of IConnectionPoint (CShellBrowser) advertises DIID_DWebBrowserEvents,
47 but fires events to IDispatch.
48 */
49 template<class T, const IID *piid, class CDV = CComDynamicUnkArray>
50 class MyIConnectionPointImpl : public IConnectionPointImpl<T, piid, CDV>
51 {
52 public:
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)
71 return CONNECT_E_CANNOTCONNECT;
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 };