ReactOS 0.4.16-dev-106-g10b08aa
CFolderOptions.cpp
Go to the documentation of this file.
1/*
2 * Folder options.
3 *
4 * Copyright (C) 2016 Mark Jansen
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <precomp.h>
22#include <shdeprecated.h>
23
24
26
28 :m_pSite(NULL)
29{
30}
31
33{
34}
35
36/*************************************************************************
37 * FolderOptions IShellPropSheetExt interface
38 */
39
43
45{
46 HPROPSHEETPAGE hPage;
47 LPARAM sheetparam = (LPARAM)static_cast<CFolderOptions*>(this);
48
50 if (hPage == NULL)
51 {
52 ERR("Failed to create property sheet page FolderOptionsGeneral\n");
53 return E_FAIL;
54 }
55 if (!pfnAddPage(hPage, lParam))
56 return E_FAIL;
57
59 if (hPage == NULL)
60 {
61 ERR("Failed to create property sheet page FolderOptionsView\n");
62 return E_FAIL;
63 }
64 if (!pfnAddPage(hPage, lParam))
65 return E_FAIL;
66
68 if (hPage == NULL)
69 {
70 ERR("Failed to create property sheet page FolderOptionsFileTypes\n");
71 return E_FAIL;
72 }
73 if (!pfnAddPage(hPage, lParam))
74 return E_FAIL;
75
76 return S_OK;
77}
78
80{
81 TRACE("(%p) (uPageID %u, pfnReplaceWith %p lParam %p\n", this, uPageID, pfnReplaceWith, lParam);
82 return E_NOTIMPL;
83}
84
85/*************************************************************************
86 * FolderOptions IShellExtInit interface
87 */
88
90{
91 return S_OK;
92}
93
94
95/*************************************************************************
96 * FolderOptions IObjectWithSite interface
97 */
99{
100 m_pSite = pUnkSite;
101 return S_OK;
102}
103
105{
106 return m_pSite ? m_pSite->QueryInterface(riid, ppvSite) : E_FAIL;
107}
108
109/*************************************************************************
110 * FolderOptions helper methods
111 */
113{
114 IBrowserService2 *bs2;
116 if (SUCCEEDED(hr))
117 {
118 if (Action == DFSA_APPLY)
119 {
120 hr = bs2->SetAsDefFolderSettings();
121 }
122 else if (Action == DFSA_RESET)
123 {
124 // There does not seem to be a method in IBrowserService2 for this
125 IUnknown_Exec(bs2, CGID_DefView, DVCMDID_RESET_DEFAULTFOLDER_SETTINGS, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
126 }
127 else
128 {
129 // FFSA_QUERY: hr is already correct
130 }
131 bs2->Release();
132 }
133
134 if (Action == DFSA_RESET)
135 {
136 IGlobalFolderSettings *pgfs;
137 HRESULT hr = CoCreateInstance(CLSID_GlobalFolderSettings, NULL, CLSCTX_INPROC_SERVER,
138 IID_IGlobalFolderSettings, (void **)&pgfs);
139 if (SUCCEEDED(hr))
140 {
141 hr = pgfs->Set(NULL, 0, 0);
142 pgfs->Release();
143 }
144 }
145
146 return hr;
147}
INT_PTR CALLBACK FolderOptionsViewDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: view.cpp:953
INT_PTR CALLBACK FolderOptionsFileTypesDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1691
INT_PTR CALLBACK FolderOptionsGeneralDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.cpp:331
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ERR(fmt,...)
Definition: precomp.h:57
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
STDMETHOD() AddPages(LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam) override
HRESULT HandleDefFolderSettings(int Action)
STDMETHOD() GetSite(REFIID riid, void **ppvSite) override
CComPtr< IUnknown > m_pSite
STDMETHOD() Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override
STDMETHOD() SetSite(IUnknown *pUnkSite) override
STDMETHOD() ReplacePage(EXPPS uPageID, LPFNSVADDPROPSHEETPAGE pfnReplaceWith, LPARAM lParam) override
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define CALLBACK
Definition: compat.h:35
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1501
HRESULT WINAPI IUnknown_Exec(IUnknown *lpUnknown, REFGUID pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
Definition: ordinal.c:1087
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
REFIID riid
Definition: atlbase.h:39
HRESULT SetAsDefFolderSettings()
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define SID_SShellBrowser
Definition: shlguid.h:128
#define DVCMDID_RESET_DEFAULTFOLDER_SETTINGS
Definition: shlobj_undoc.h:90
LPARAM LPFNSVADDPROPSHEETPAGE
Definition: shobjidl.idl:117
#define IDD_FOLDER_OPTIONS_FILETYPES
Definition: shresdef.h:413
#define IDD_FOLDER_OPTIONS_GENERAL
Definition: shresdef.h:411
#define IDD_FOLDER_OPTIONS_VIEW
Definition: shresdef.h:412
#define TRACE(s)
Definition: solgame.cpp:4
int32_t INT_PTR
Definition: typedefs.h:64
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define IID_PPV_ARG(Itype, ppType)