ReactOS 0.4.16-dev-252-g9ccafe8
CDefViewUtil.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: shell32
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: DefView utility functions
5 * COPYRIGHT: Copyright 2024 Whindmar Saksit <whindsaks@proton.me>
6 */
7
8#include "precomp.h"
9
11
13 public IObjectWithSite
14{
15public:
17
20
21 // IObjectWithSite
22 STDMETHODIMP SetSite(IUnknown *pUnkSite) override
23 {
24 IUnknown_Set(&m_pUnkSite, pUnkSite);
25 return S_OK;
26 }
27 STDMETHODIMP GetSite(REFIID riid, void **ppvSite) override
28 {
29 *ppvSite = NULL;
30 return m_pUnkSite ? m_pUnkSite->QueryInterface(riid, ppvSite) : E_FAIL;
31 }
32};
33
34// This class adapts the legacy function callback to work as an IShellFolderViewCB
36 public CComObjectRootEx<CComMultiThreadModelNoCS>,
37 public IShellFolderViewCB,
39{
40protected:
48
49public:
51
53 {
55 }
56
58 {
59 m_psf = psvcbi->pshf;
60 m_psvOuter = psvcbi->psvOuter;
61 m_Pidl = psvcbi->pidl ? ILClone(psvcbi->pidl) : NULL;
62 m_Callback = psvcbi->pfnCallback;
63 m_FVM = psvcbi->fvm;
64 m_Events = psvcbi->lEvents;
65 return S_OK;
66 }
67
68 // IShellFolderViewCB
70 {
71 switch (uMsg)
72 {
73 case SFVM_HWNDMAIN:
75 break;
76
78 if (m_FVM)
80 break;
81 }
82
84 if (SUCCEEDED(hr))
85 return hr;
86
87 switch (uMsg)
88 {
89 case SFVM_GETNOTIFY:
91 *(LONG*)lParam = m_Events;
92 return S_OK;
93 }
94 return hr;
95 }
96
97 // IObjectWithSite
98 STDMETHODIMP SetSite(IUnknown *pUnkSite) override
99 {
100 // learn.microsoft.com/en-us/windows/win32/shell/sfvm-setisfv
102 MessageSFVCB(SFVM_SETISFV, 0, (LPARAM)pUnkSite);
103 return hr;
104 }
105
109 COM_INTERFACE_ENTRY_IID(IID_IShellFolderViewCB, IShellFolderViewCB)
112};
113
114/*************************************************************************
115 * SHCreateShellFolderViewEx [SHELL32.174] (Win95+)
116 */
119{
120 if (!ppsv)
121 return E_INVALIDARG;
122 *ppsv = NULL;
123
124 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x outer=%p\n",
125 pcsfv->pshf, pcsfv->pidl, pcsfv->pfnCallback,
126 pcsfv->fvm, pcsfv->psvOuter);
127
129 SFV_CREATE create = { sizeof(create), pcsfv->pshf, pcsfv->psvOuter };
130
131 if (pcsfv->pfnCallback)
132 {
133 HRESULT hr = ShellObjectCreatorInit<CShellFolderViewCBWrapper>(pcsfv,
134 IID_PPV_ARG(IShellFolderViewCB, &psfvcb));
135 if (FAILED(hr))
136 return hr;
137 create.psfvcb = psfvcb;
138 }
139 return SHCreateShellFolderView(&create, ppsv);
140}
EXTERN_C HRESULT WINAPI SHCreateShellFolderViewEx(_In_ LPCSFV pcsfv, _Out_ IShellView **ppsv)
HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **ppsv)
Definition: CDefView.cpp:4663
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define EXTERN_C
Definition: basetyps.h:12
#define STDMETHODIMP
Definition: basetyps.h:43
STDMETHODIMP SetSite(IUnknown *pUnkSite) override
STDMETHODIMP GetSite(REFIID riid, void **ppvSite) override
virtual ~CObjectWithSiteBase()
HRESULT WINAPI Initialize(LPCSFV psvcbi)
CComPtr< IShellView > m_psvOuter
LPFNVIEWCALLBACK m_Callback
virtual ~CShellFolderViewCBWrapper()
STDMETHODIMP MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam) override
STDMETHODIMP SetSite(IUnknown *pUnkSite) override
PIDLIST_ABSOLUTE m_Pidl
CComPtr< IShellFolder > m_psf
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
HANDLE HWND
Definition: compat.h:19
VOID WINAPI IUnknown_Set(IUnknown **lppDest, IUnknown *lpUnknown)
Definition: ordinal.c:2190
REFIID riid
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:581
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:601
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:651
#define END_COM_MAP()
Definition: atlcom.h:592
#define DECLARE_NO_REGISTRY()
Definition: atlcom.h:639
const IID IID_IObjectWithSite
static const struct access_res create[16]
Definition: package.c:7505
unsigned int UINT
Definition: ndis.h:50
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
long LONG
Definition: pedump.c:60
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:946
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define SFVM_DEFVIEWMODE
Definition: shlobj.h:1318
HRESULT(CALLBACK * LPFNVIEWCALLBACK)(_In_ IShellView *dwUser, _In_ IShellFolder *pshf, _In_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shlobj.h:1264
#define SFVM_HWNDMAIN
Definition: shlobj.h:1334
#define SFVM_GETNOTIFY
Definition: shlobj.h:1337
#define SFVM_SETISFV
Definition: shlobj.h:1330
FOLDERVIEWMODE
Definition: shobjidl.idl:677
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define TRACE(s)
Definition: solgame.cpp:4
Definition: shlobj.h:1275
FOLDERVIEWMODE fvm
Definition: shlobj.h:1282
IShellView * psvOuter
Definition: shlobj.h:1278
LPFNVIEWCALLBACK pfnCallback
Definition: shlobj.h:1281
LONG lEvents
Definition: shlobj.h:1280
PCIDLIST_ABSOLUTE pidl
Definition: shlobj.h:1279
IShellFolder * pshf
Definition: shlobj.h:1277
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define IID_PPV_ARG(Itype, ppType)