mirror of
https://github.com/reactos/reactos.git
synced 2024-09-03 17:19:20 +00:00
[SHELL32][BROWSEUI] Implement ShellBrowser Apply/Reset default folder settings (#6912)
This commit is contained in:
parent
ad73e17418
commit
c97c1ad4c5
|
@ -20,6 +20,52 @@
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
|
#define DEFBROWSERSTREAM L"Settings"
|
||||||
|
#define DEFAULT_VID GUID_NULL // We don't support WebView
|
||||||
|
#define CURRENT_VERSION ( DEFFOLDERSETTINGS::VER_XP )
|
||||||
|
|
||||||
|
template<class S, class D> static void CopyTo(const S &Src, D &Dst)
|
||||||
|
{
|
||||||
|
Dst.FolderSettings = Src.FolderSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EnsureValid(FOLDERSETTINGS &fs)
|
||||||
|
{
|
||||||
|
if ((int)fs.ViewMode < FVM_AUTO || (int)fs.ViewMode > FVM_LAST)
|
||||||
|
fs.ViewMode = SBFOLDERSETTINGS::DEF_FVM;
|
||||||
|
|
||||||
|
fs.fFlags &= ~(FWF_OWNERDATA | FWF_DESKTOP | FWF_TRANSPARENT | FWF_NOCLIENTEDGE |
|
||||||
|
FWF_NOSUBFOLDERS | FWF_NOSCROLL | FWF_NOENUMREFRESH | FWF_NOVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EnsureValid(DEFFOLDERSETTINGS &dfs)
|
||||||
|
{
|
||||||
|
EnsureValid(dfs.FolderSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InitializeDefaults(DEFFOLDERSETTINGS &dfs)
|
||||||
|
{
|
||||||
|
C_ASSERT(FIELD_OFFSET(DEFFOLDERSETTINGS, FolderSettings) == 4);
|
||||||
|
C_ASSERT(FIELD_OFFSET(DEFFOLDERSETTINGS, ViewPriority) == DEFFOLDERSETTINGS::SIZE_IE4);
|
||||||
|
C_ASSERT(sizeof(DEFFOLDERSETTINGS) == DEFFOLDERSETTINGS::SIZE_XP);
|
||||||
|
|
||||||
|
*(UINT*)&dfs = FALSE; // Set all unknown flags to FALSE
|
||||||
|
dfs.Statusbar = TRUE;
|
||||||
|
dfs.FolderSettings.ViewMode = SBFOLDERSETTINGS::DEF_FVM;
|
||||||
|
dfs.FolderSettings.fFlags = SBFOLDERSETTINGS::DEF_FWF;
|
||||||
|
dfs.vid = DEFAULT_VID;
|
||||||
|
dfs.Version = CURRENT_VERSION;
|
||||||
|
dfs.Counter = 0;
|
||||||
|
dfs.ViewPriority = VIEW_PRIORITY_CACHEMISS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBFOLDERSETTINGS::Load()
|
||||||
|
{
|
||||||
|
DEFFOLDERSETTINGS dfs;
|
||||||
|
CGlobalFolderSettings::Load(dfs);
|
||||||
|
CopyTo(dfs, *this);
|
||||||
|
}
|
||||||
|
|
||||||
CGlobalFolderSettings::CGlobalFolderSettings()
|
CGlobalFolderSettings::CGlobalFolderSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -28,13 +74,83 @@ CGlobalFolderSettings::~CGlobalFolderSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CGlobalFolderSettings::Get(DEFFOLDERSETTINGS *paramC, int param10)
|
HRESULT CGlobalFolderSettings::ResetBrowserSettings()
|
||||||
{
|
{
|
||||||
return E_NOTIMPL;
|
return Save(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CGlobalFolderSettings::Set(
|
HRESULT CGlobalFolderSettings::SaveBrowserSettings(const SBFOLDERSETTINGS &sbfs)
|
||||||
const DEFFOLDERSETTINGS *paramC, int param10, unsigned int param14)
|
|
||||||
{
|
{
|
||||||
return E_NOTIMPL;
|
DEFFOLDERSETTINGS dfs;
|
||||||
|
InitializeDefaults(dfs);
|
||||||
|
CopyTo(sbfs, dfs);
|
||||||
|
return Save(&dfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CGlobalFolderSettings::Load(DEFFOLDERSETTINGS &dfs)
|
||||||
|
{
|
||||||
|
HKEY hStreamsKey = SHGetShellKey(SHKEY_Key_Explorer, L"Streams", FALSE);
|
||||||
|
if (hStreamsKey)
|
||||||
|
{
|
||||||
|
DWORD cb = sizeof(DEFFOLDERSETTINGS);
|
||||||
|
DWORD err = SHRegGetValueW(hStreamsKey, NULL, DEFBROWSERSTREAM,
|
||||||
|
SRRF_RT_REG_BINARY, NULL, &dfs, &cb);
|
||||||
|
RegCloseKey(hStreamsKey);
|
||||||
|
if (!err && cb >= DEFFOLDERSETTINGS::SIZE_NT4)
|
||||||
|
{
|
||||||
|
if (cb < FIELD_OFFSET(DEFFOLDERSETTINGS, vid))
|
||||||
|
{
|
||||||
|
dfs.FolderSettings.fFlags = SBFOLDERSETTINGS::DEF_FWF;
|
||||||
|
}
|
||||||
|
if (cb < FIELD_OFFSET(DEFFOLDERSETTINGS, Version))
|
||||||
|
{
|
||||||
|
dfs.vid = DEFAULT_VID;
|
||||||
|
}
|
||||||
|
if (cb <= FIELD_OFFSET(DEFFOLDERSETTINGS, ViewPriority))
|
||||||
|
{
|
||||||
|
dfs.Version = CURRENT_VERSION;
|
||||||
|
}
|
||||||
|
dfs.ViewPriority = VIEW_PRIORITY_STALECACHEHIT;
|
||||||
|
EnsureValid(dfs);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InitializeDefaults(dfs);
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CGlobalFolderSettings::Save(const DEFFOLDERSETTINGS *pFDS)
|
||||||
|
{
|
||||||
|
HKEY hStreamsKey = SHGetShellKey(SHKEY_Key_Explorer, L"Streams", TRUE);
|
||||||
|
if (!hStreamsKey)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
HRESULT hr = E_INVALIDARG;
|
||||||
|
if (!pFDS)
|
||||||
|
{
|
||||||
|
DWORD err = SHDeleteValueW(hStreamsKey, NULL, DEFBROWSERSTREAM);
|
||||||
|
hr = (!err || err == ERROR_FILE_NOT_FOUND) ? S_OK : HResultFromWin32(err);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DWORD cb = sizeof(DEFFOLDERSETTINGS);
|
||||||
|
hr = HResultFromWin32(SHSetValueW(hStreamsKey, NULL, DEFBROWSERSTREAM, REG_BINARY, pFDS, cb));
|
||||||
|
}
|
||||||
|
RegCloseKey(hStreamsKey);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE CGlobalFolderSettings::Get(struct DEFFOLDERSETTINGS *pFDS, UINT cb)
|
||||||
|
{
|
||||||
|
if (cb != sizeof(DEFFOLDERSETTINGS) || !pFDS)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
return Load(*pFDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE CGlobalFolderSettings::Set(const struct DEFFOLDERSETTINGS *pFDS, UINT cb, UINT unknown)
|
||||||
|
{
|
||||||
|
// NULL pFDS means reset
|
||||||
|
if (cb != sizeof(DEFFOLDERSETTINGS) && pFDS)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
return Save(pFDS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
struct SBFOLDERSETTINGS // Private version of DEFFOLDERSETTINGS used by CShellBrowser
|
||||||
|
{
|
||||||
|
FOLDERSETTINGS FolderSettings;
|
||||||
|
|
||||||
|
enum { DEF_FVM = FVM_DETAILS }; // Windows uses FVM_ICON?
|
||||||
|
enum { DEF_FWF = FWF_NOHEADERINALLVIEWS };
|
||||||
|
void InitializeDefaults()
|
||||||
|
{
|
||||||
|
FolderSettings.ViewMode = DEF_FVM;
|
||||||
|
FolderSettings.fFlags = DEF_FWF;
|
||||||
|
}
|
||||||
|
void Load();
|
||||||
|
};
|
||||||
|
|
||||||
class CGlobalFolderSettings :
|
class CGlobalFolderSettings :
|
||||||
public CComCoClass<CGlobalFolderSettings, &CLSID_GlobalFolderSettings>,
|
public CComCoClass<CGlobalFolderSettings, &CLSID_GlobalFolderSettings>,
|
||||||
public CComObjectRootEx<CComMultiThreadModelNoCS>,
|
public CComObjectRootEx<CComMultiThreadModelNoCS>,
|
||||||
|
@ -30,9 +44,14 @@ public:
|
||||||
CGlobalFolderSettings();
|
CGlobalFolderSettings();
|
||||||
~CGlobalFolderSettings();
|
~CGlobalFolderSettings();
|
||||||
|
|
||||||
|
static HRESULT ResetBrowserSettings();
|
||||||
|
static HRESULT SaveBrowserSettings(const SBFOLDERSETTINGS &sbfs);
|
||||||
|
static HRESULT Load(DEFFOLDERSETTINGS &dfs);
|
||||||
|
static HRESULT Save(const DEFFOLDERSETTINGS *pFDS);
|
||||||
|
|
||||||
// *** IGlobalFolderSettings methods ***
|
// *** IGlobalFolderSettings methods ***
|
||||||
STDMETHOD(Get)(DEFFOLDERSETTINGS *paramC, int param10) override;
|
STDMETHOD(Get)(struct DEFFOLDERSETTINGS *pFDS, UINT cb) override;
|
||||||
STDMETHOD(Set)(const DEFFOLDERSETTINGS *paramC, int param10, unsigned int param14) override;
|
STDMETHOD(Set)(const struct DEFFOLDERSETTINGS *pFDS, UINT cb, UINT unknown) override;
|
||||||
|
|
||||||
DECLARE_REGISTRY_RESOURCEID(IDR_GLOBALFOLDERSETTINGS)
|
DECLARE_REGISTRY_RESOURCEID(IDR_GLOBALFOLDERSETTINGS)
|
||||||
DECLARE_NOT_AGGREGATABLE(CGlobalFolderSettings)
|
DECLARE_NOT_AGGREGATABLE(CGlobalFolderSettings)
|
||||||
|
|
|
@ -24,7 +24,7 @@ void ShellSettings::Save()
|
||||||
void ShellSettings::Load()
|
void ShellSettings::Load()
|
||||||
{
|
{
|
||||||
fStatusBarVisible = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main",
|
fStatusBarVisible = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main",
|
||||||
L"StatusBarOther", FALSE, FALSE);
|
L"StatusBarOther", FALSE, TRUE);
|
||||||
|
|
||||||
fShowGoButton = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main",
|
fShowGoButton = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main",
|
||||||
L"ShowGoButton", FALSE, TRUE);
|
L"ShowGoButton", FALSE, TRUE);
|
||||||
|
|
|
@ -12,12 +12,13 @@
|
||||||
|
|
||||||
struct ShellSettings
|
struct ShellSettings
|
||||||
{
|
{
|
||||||
BOOL fLocked = FALSE;
|
BOOL fLocked = TRUE;
|
||||||
BOOL fShowGoButton = FALSE;
|
BOOL fShowGoButton = TRUE;
|
||||||
BOOL fStatusBarVisible = FALSE;
|
BOOL fStatusBarVisible = TRUE;
|
||||||
|
|
||||||
void Save();
|
void Save();
|
||||||
void Load();
|
void Load();
|
||||||
|
void Reset() { ShellSettings().Save(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CabinetStateSettings : CABINETSTATE
|
struct CabinetStateSettings : CABINETSTATE
|
||||||
|
|
|
@ -305,6 +305,7 @@ private:
|
||||||
HDSA menuDsa;
|
HDSA menuDsa;
|
||||||
HACCEL m_hAccel;
|
HACCEL m_hAccel;
|
||||||
ShellSettings m_settings;
|
ShellSettings m_settings;
|
||||||
|
SBFOLDERSETTINGS m_deffoldersettings;
|
||||||
public:
|
public:
|
||||||
#if 0
|
#if 0
|
||||||
ULONG InternalAddRef()
|
ULONG InternalAddRef()
|
||||||
|
@ -332,6 +333,7 @@ public:
|
||||||
HRESULT ShowBand(const CLSID &classID, bool vertical);
|
HRESULT ShowBand(const CLSID &classID, bool vertical);
|
||||||
HRESULT NavigateToParent();
|
HRESULT NavigateToParent();
|
||||||
HRESULT DoFolderOptions();
|
HRESULT DoFolderOptions();
|
||||||
|
HRESULT ApplyBrowserDefaultFolderSettings(IShellView *pvs);
|
||||||
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
void RepositionBars();
|
void RepositionBars();
|
||||||
HRESULT BuildExplorerBandMenu();
|
HRESULT BuildExplorerBandMenu();
|
||||||
|
@ -723,6 +725,7 @@ CShellBrowser::CShellBrowser()
|
||||||
fHistoryStream = NULL;
|
fHistoryStream = NULL;
|
||||||
fHistoryBindContext = NULL;
|
fHistoryBindContext = NULL;
|
||||||
m_settings.Load();
|
m_settings.Load();
|
||||||
|
m_deffoldersettings.Load();
|
||||||
gCabinetState.Load();
|
gCabinetState.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,10 +805,32 @@ HRESULT CShellBrowser::Initialize()
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT CShellBrowser::ApplyBrowserDefaultFolderSettings(IShellView *pvs)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
if (pvs)
|
||||||
|
{
|
||||||
|
m_settings.Save();
|
||||||
|
SBFOLDERSETTINGS &sbfs = m_deffoldersettings, defsbfs;
|
||||||
|
if (FAILED(pvs->GetCurrentInfo(&sbfs.FolderSettings)))
|
||||||
|
{
|
||||||
|
defsbfs.InitializeDefaults();
|
||||||
|
sbfs = defsbfs;
|
||||||
|
}
|
||||||
|
hr = CGlobalFolderSettings::SaveBrowserSettings(sbfs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_settings.Reset();
|
||||||
|
hr = CGlobalFolderSettings::ResetBrowserSettings();
|
||||||
|
}
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT CShellBrowser::BrowseToPIDL(LPCITEMIDLIST pidl, long flags)
|
HRESULT CShellBrowser::BrowseToPIDL(LPCITEMIDLIST pidl, long flags)
|
||||||
{
|
{
|
||||||
CComPtr<IShellFolder> newFolder;
|
CComPtr<IShellFolder> newFolder;
|
||||||
FOLDERSETTINGS newFolderSettings;
|
FOLDERSETTINGS newFolderSettings = m_deffoldersettings.FolderSettings;
|
||||||
HRESULT hResult;
|
HRESULT hResult;
|
||||||
CLSID clsid;
|
CLSID clsid;
|
||||||
BOOL HasIconViewType;
|
BOOL HasIconViewType;
|
||||||
|
@ -822,9 +847,6 @@ HRESULT CShellBrowser::BrowseToPIDL(LPCITEMIDLIST pidl, long flags)
|
||||||
|
|
||||||
if (HasIconViewType)
|
if (HasIconViewType)
|
||||||
newFolderSettings.ViewMode = FVM_ICON;
|
newFolderSettings.ViewMode = FVM_ICON;
|
||||||
else
|
|
||||||
newFolderSettings.ViewMode = FVM_DETAILS;
|
|
||||||
newFolderSettings.fFlags = 0;
|
|
||||||
hResult = BrowseToPath(newFolder, pidl, &newFolderSettings, flags);
|
hResult = BrowseToPath(newFolder, pidl, &newFolderSettings, flags);
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
return hResult;
|
return hResult;
|
||||||
|
@ -2128,8 +2150,8 @@ HRESULT STDMETHODCALLTYPE CShellBrowser::Exec(const GUID *pguidCmdGroup, DWORD n
|
||||||
{
|
{
|
||||||
switch (nCmdID)
|
switch (nCmdID)
|
||||||
{
|
{
|
||||||
case 1:
|
case DVCMDID_RESET_DEFAULTFOLDER_SETTINGS:
|
||||||
// Reset All Folders option in Folder Options
|
IUnknown_Exec(fCurrentShellView, CGID_DefView, nCmdID, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2644,7 +2666,13 @@ LRESULT STDMETHODCALLTYPE CShellBrowser::WndProcBS(HWND hwnd, UINT uMsg, WPARAM
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CShellBrowser::SetAsDefFolderSettings()
|
HRESULT STDMETHODCALLTYPE CShellBrowser::SetAsDefFolderSettings()
|
||||||
{
|
{
|
||||||
return E_NOTIMPL;
|
HRESULT hr = E_FAIL;
|
||||||
|
if (fCurrentShellView)
|
||||||
|
{
|
||||||
|
hr = ApplyBrowserDefaultFolderSettings(fCurrentShellView);
|
||||||
|
IUnknown_Exec(fCurrentShellView, CGID_DefView, DVCMDID_SET_DEFAULTFOLDER_SETTINGS, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
|
||||||
|
}
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewRect(RECT *prc)
|
HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewRect(RECT *prc)
|
||||||
|
|
|
@ -2451,9 +2451,7 @@ SelectExtOnRename(void)
|
||||||
LONG error;
|
LONG error;
|
||||||
DWORD dwValue = FALSE, cbValue;
|
DWORD dwValue = FALSE, cbValue;
|
||||||
|
|
||||||
error = RegOpenKeyExW(HKEY_CURRENT_USER,
|
error = RegOpenKeyExW(HKEY_CURRENT_USER, REGSTR_PATH_EXPLORER, 0, KEY_READ, &hKey);
|
||||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer",
|
|
||||||
0, KEY_READ, &hKey);
|
|
||||||
if (error)
|
if (error)
|
||||||
return dwValue;
|
return dwValue;
|
||||||
|
|
||||||
|
@ -3792,6 +3790,23 @@ HRESULT WINAPI CDefView::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCm
|
||||||
(nCmdexecopt == 0))
|
(nCmdexecopt == 0))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (IsEqualIID(*pguidCmdGroup, CGID_DefView))
|
||||||
|
{
|
||||||
|
WCHAR SubKey[MAX_PATH];
|
||||||
|
switch (nCmdID)
|
||||||
|
{
|
||||||
|
case DVCMDID_SET_DEFAULTFOLDER_SETTINGS:
|
||||||
|
SHDeleteKey(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\ShellNoRoam\\Bags");
|
||||||
|
FIXME("Save current as default\n");
|
||||||
|
break;
|
||||||
|
case DVCMDID_RESET_DEFAULTFOLDER_SETTINGS:
|
||||||
|
wsprintfW(SubKey, L"%s\\%s", REGSTR_PATH_EXPLORER, L"Streams\\Default");
|
||||||
|
SHDeleteKey(HKEY_CURRENT_USER, SubKey);
|
||||||
|
SHDeleteKey(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\ShellNoRoam\\Bags");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return OLECMDERR_E_UNKNOWNGROUP;
|
return OLECMDERR_E_UNKNOWNGROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <precomp.h>
|
#include <precomp.h>
|
||||||
|
#include <shdeprecated.h>
|
||||||
|
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(fprop);
|
WINE_DEFAULT_DEBUG_CHANNEL(fprop);
|
||||||
|
@ -42,8 +43,10 @@ INT_PTR CALLBACK FolderOptionsFileTypesDlg(HWND hwndDlg, UINT uMsg, WPARAM wPara
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CFolderOptions::AddPages(LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
|
HRESULT STDMETHODCALLTYPE CFolderOptions::AddPages(LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HPROPSHEETPAGE hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_GENERAL, FolderOptionsGeneralDlg, 0, NULL);
|
HPROPSHEETPAGE hPage;
|
||||||
|
LPARAM sheetparam = (LPARAM)static_cast<CFolderOptions*>(this);
|
||||||
|
|
||||||
|
hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_GENERAL, FolderOptionsGeneralDlg, sheetparam, NULL);
|
||||||
if (hPage == NULL)
|
if (hPage == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to create property sheet page FolderOptionsGeneral\n");
|
ERR("Failed to create property sheet page FolderOptionsGeneral\n");
|
||||||
|
@ -52,7 +55,7 @@ HRESULT STDMETHODCALLTYPE CFolderOptions::AddPages(LPFNSVADDPROPSHEETPAGE pfnAdd
|
||||||
if (!pfnAddPage(hPage, lParam))
|
if (!pfnAddPage(hPage, lParam))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_VIEW, FolderOptionsViewDlg, 0, NULL);
|
hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_VIEW, FolderOptionsViewDlg, sheetparam, NULL);
|
||||||
if (hPage == NULL)
|
if (hPage == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to create property sheet page FolderOptionsView\n");
|
ERR("Failed to create property sheet page FolderOptionsView\n");
|
||||||
|
@ -61,7 +64,7 @@ HRESULT STDMETHODCALLTYPE CFolderOptions::AddPages(LPFNSVADDPROPSHEETPAGE pfnAdd
|
||||||
if (!pfnAddPage(hPage, lParam))
|
if (!pfnAddPage(hPage, lParam))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_FILETYPES, FolderOptionsFileTypesDlg, 0, NULL);
|
hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_FILETYPES, FolderOptionsFileTypesDlg, sheetparam, NULL);
|
||||||
if (hPage == NULL)
|
if (hPage == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to create property sheet page FolderOptionsFileTypes\n");
|
ERR("Failed to create property sheet page FolderOptionsFileTypes\n");
|
||||||
|
@ -90,7 +93,7 @@ HRESULT STDMETHODCALLTYPE CFolderOptions::Initialize(PCIDLIST_ABSOLUTE pidlFolde
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* FolderOptions IShellExtInit interface
|
* FolderOptions IObjectWithSite interface
|
||||||
*/
|
*/
|
||||||
HRESULT STDMETHODCALLTYPE CFolderOptions::SetSite(IUnknown *pUnkSite)
|
HRESULT STDMETHODCALLTYPE CFolderOptions::SetSite(IUnknown *pUnkSite)
|
||||||
{
|
{
|
||||||
|
@ -100,6 +103,45 @@ HRESULT STDMETHODCALLTYPE CFolderOptions::SetSite(IUnknown *pUnkSite)
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CFolderOptions::GetSite(REFIID riid, void **ppvSite)
|
HRESULT STDMETHODCALLTYPE CFolderOptions::GetSite(REFIID riid, void **ppvSite)
|
||||||
{
|
{
|
||||||
return m_pSite->QueryInterface(riid, ppvSite);
|
return m_pSite ? m_pSite->QueryInterface(riid, ppvSite) : E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
* FolderOptions helper methods
|
||||||
|
*/
|
||||||
|
HRESULT CFolderOptions::HandleDefFolderSettings(int Action)
|
||||||
|
{
|
||||||
|
IBrowserService2 *bs2;
|
||||||
|
HRESULT hr = IUnknown_QueryService(m_pSite, SID_SShellBrowser, IID_PPV_ARG(IBrowserService2, &bs2));
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
if (Action == DFSA_APPLY)
|
||||||
|
{
|
||||||
|
hr = bs2->SetAsDefFolderSettings();
|
||||||
|
}
|
||||||
|
else if (Action == DFSA_RESET)
|
||||||
|
{
|
||||||
|
// There does not seem to be a method in IBrowserService2 for this
|
||||||
|
IUnknown_Exec(bs2, CGID_DefView, DVCMDID_RESET_DEFAULTFOLDER_SETTINGS, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FFSA_QUERY: hr is already correct
|
||||||
|
}
|
||||||
|
bs2->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Action == DFSA_RESET)
|
||||||
|
{
|
||||||
|
IGlobalFolderSettings *pgfs;
|
||||||
|
HRESULT hr = CoCreateInstance(CLSID_GlobalFolderSettings, NULL, CLSCTX_INPROC_SERVER,
|
||||||
|
IID_IGlobalFolderSettings, (void **)&pgfs);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
hr = pgfs->Set(NULL, 0, 0);
|
||||||
|
pgfs->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,10 @@ class CFolderOptions :
|
||||||
//BOOL QueryDrop (DWORD dwKeyState, LPDWORD pdwEffect);
|
//BOOL QueryDrop (DWORD dwKeyState, LPDWORD pdwEffect);
|
||||||
//BOOL RecycleBinIsEmpty();
|
//BOOL RecycleBinIsEmpty();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum DEFFOLDERSETTINGACTION { DFSA_QUERY = -1, DFSA_RESET, DFSA_APPLY };
|
||||||
|
HRESULT HandleDefFolderSettings(int Action);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFolderOptions();
|
CFolderOptions();
|
||||||
~CFolderOptions();
|
~CFolderOptions();
|
||||||
|
@ -53,6 +57,15 @@ class CFolderOptions :
|
||||||
STDMETHOD(SetSite)(IUnknown *pUnkSite) override;
|
STDMETHOD(SetSite)(IUnknown *pUnkSite) override;
|
||||||
STDMETHOD(GetSite)(REFIID riid, void **ppvSite) override;
|
STDMETHOD(GetSite)(REFIID riid, void **ppvSite) override;
|
||||||
|
|
||||||
|
bool CanSetDefFolderSettings()
|
||||||
|
{
|
||||||
|
return SUCCEEDED(HandleDefFolderSettings(DFSA_QUERY));
|
||||||
|
}
|
||||||
|
HRESULT ApplyDefFolderSettings(bool ResetToDefault)
|
||||||
|
{
|
||||||
|
return HandleDefFolderSettings(ResetToDefault ? DFSA_RESET : DFSA_APPLY);
|
||||||
|
}
|
||||||
|
|
||||||
DECLARE_REGISTRY_RESOURCEID(IDR_FOLDEROPTIONS)
|
DECLARE_REGISTRY_RESOURCEID(IDR_FOLDEROPTIONS)
|
||||||
DECLARE_NOT_AGGREGATABLE(CFolderOptions)
|
DECLARE_NOT_AGGREGATABLE(CFolderOptions)
|
||||||
|
|
||||||
|
|
|
@ -618,8 +618,18 @@ ViewDlg_CreateTreeImageList(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
ViewDlg_OnInitDialog(HWND hwndDlg)
|
ViewDlg_OnInitDialog(HWND hwndDlg, LPPROPSHEETPAGE psp)
|
||||||
{
|
{
|
||||||
|
SetWindowLongPtr(hwndDlg, GWL_USERDATA, psp->lParam);
|
||||||
|
CFolderOptions *pFO = (CFolderOptions*)psp->lParam;
|
||||||
|
|
||||||
|
if (!pFO || !pFO->CanSetDefFolderSettings())
|
||||||
|
{
|
||||||
|
// The global options (started from rundll32 or control panel)
|
||||||
|
// has no browser to copy the current settings from.
|
||||||
|
EnableWindow(GetDlgItem(hwndDlg, IDC_VIEW_APPLY_TO_ALL), FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
HWND hwndTreeView = GetDlgItem(hwndDlg, IDC_VIEW_TREEVIEW);
|
HWND hwndTreeView = GetDlgItem(hwndDlg, IDC_VIEW_TREEVIEW);
|
||||||
|
|
||||||
s_hTreeImageList = ViewDlg_CreateTreeImageList();
|
s_hTreeImageList = ViewDlg_CreateTreeImageList();
|
||||||
|
@ -941,7 +951,7 @@ FolderOptionsViewDlg(
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
return ViewDlg_OnInitDialog(hwndDlg);
|
return ViewDlg_OnInitDialog(hwndDlg, (LPPROPSHEETPAGE)lParam);
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
|
@ -949,6 +959,18 @@ FolderOptionsViewDlg(
|
||||||
case IDC_VIEW_RESTORE_DEFAULTS: // Restore Defaults
|
case IDC_VIEW_RESTORE_DEFAULTS: // Restore Defaults
|
||||||
ViewDlg_RestoreDefaults(hwndDlg);
|
ViewDlg_RestoreDefaults(hwndDlg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDC_VIEW_APPLY_TO_ALL:
|
||||||
|
case IDC_VIEW_RESET_ALL:
|
||||||
|
{
|
||||||
|
HRESULT hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
|
CFolderOptions *pFO = (CFolderOptions*)GetWindowLongPtr(hwndDlg, GWL_USERDATA);
|
||||||
|
if (pFO)
|
||||||
|
hr = pFO->ApplyDefFolderSettings(LOWORD(wParam) == IDC_VIEW_RESET_ALL);
|
||||||
|
if (FAILED(hr))
|
||||||
|
SHELL_ErrorBox(hwndDlg, hr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <powrprof.h>
|
#include <powrprof.h>
|
||||||
#include <winnetwk.h>
|
#include <winnetwk.h>
|
||||||
#include <objsafe.h>
|
#include <objsafe.h>
|
||||||
|
#include <regstr.h>
|
||||||
|
|
||||||
#include <comctl32_undoc.h>
|
#include <comctl32_undoc.h>
|
||||||
#include <shlguid_undoc.h>
|
#include <shlguid_undoc.h>
|
||||||
|
|
|
@ -94,6 +94,36 @@ inline BOOL _ROS_FAILED_HELPER(HRESULT hr, const char* expr, const char* filenam
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif /* defined(__cplusplus) */
|
#endif /* defined(__cplusplus) */
|
||||||
|
|
||||||
|
static inline UINT
|
||||||
|
SHELL_ErrorBoxHelper(HWND hwndOwner, UINT Error)
|
||||||
|
{
|
||||||
|
WCHAR buf[400];
|
||||||
|
UINT cch;
|
||||||
|
|
||||||
|
if (!IsWindowVisible(hwndOwner))
|
||||||
|
hwndOwner = NULL;
|
||||||
|
if (Error == ERROR_SUCCESS)
|
||||||
|
Error = ERROR_INTERNAL_ERROR;
|
||||||
|
|
||||||
|
cch = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL, Error, 0, buf, _countof(buf), NULL);
|
||||||
|
if (!cch)
|
||||||
|
{
|
||||||
|
enum { user32_IDS_ERROR = 2 }; // IDS_ERROR from user32 resource.h ("Error" string)
|
||||||
|
cch = LoadStringW(LoadLibraryW(L"USER32"), user32_IDS_ERROR, buf, _countof(buf));
|
||||||
|
wsprintfW(buf + cch, L"\n\n%#x (%d)", Error, Error);
|
||||||
|
}
|
||||||
|
MessageBoxW(hwndOwner, buf, NULL, MB_OK | MB_ICONSTOP);
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
#ifdef __cplusplus
|
||||||
|
template<class H> static UINT
|
||||||
|
SHELL_ErrorBox(H hwndOwner, UINT Error = GetLastError())
|
||||||
|
{
|
||||||
|
return SHELL_ErrorBoxHelper(const_cast<HWND>(hwndOwner), Error);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class CComCreatorCentralInstance
|
class CComCreatorCentralInstance
|
||||||
|
|
|
@ -83,6 +83,12 @@ struct persistState
|
||||||
#define PANE_PRIVACY 7
|
#define PANE_PRIVACY 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* CGID_DefView OLECMD IDs
|
||||||
|
*/
|
||||||
|
#define DVCMDID_SET_DEFAULTFOLDER_SETTINGS 0
|
||||||
|
#define DVCMDID_RESET_DEFAULTFOLDER_SETTINGS 1
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IInitializeObject interface
|
* IInitializeObject interface
|
||||||
*/
|
*/
|
||||||
|
@ -144,7 +150,15 @@ DECLARE_INTERFACE_(IBanneredBar, IUnknown)//, "596A9A94-013E-11d1-8D34-00A0C90F2
|
||||||
*/
|
*/
|
||||||
struct DEFFOLDERSETTINGS
|
struct DEFFOLDERSETTINGS
|
||||||
{
|
{
|
||||||
long offset0;
|
enum { SIZE_NT4 = 8, SIZE_IE4 = 36, SIZE_XP = 40 };
|
||||||
|
enum { VER_98 = 0, VER_2000 = 3, VER_XP = 4 }; // Win98SE with IE5 writes 0, not 3 as the version
|
||||||
|
UINT Statusbar : 1; // "StatusBarOther" is the new location for this
|
||||||
|
UINT Toolbar : 1; // Not used when Explorer uses ReBar
|
||||||
|
FOLDERSETTINGS FolderSettings;
|
||||||
|
SHELLVIEWID vid;
|
||||||
|
UINT Version;
|
||||||
|
UINT Counter; // Incremented every time default folder settings are applied. Invalidates a cache?
|
||||||
|
UINT ViewPriority; // VIEW_PRIORITY_*
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef INTERFACE
|
#undef INTERFACE
|
||||||
|
@ -156,8 +170,8 @@ DECLARE_INTERFACE_(IGlobalFolderSettings, IUnknown)
|
||||||
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
|
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
|
||||||
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
||||||
/*** IGlobalFolderSettings ***/
|
/*** IGlobalFolderSettings ***/
|
||||||
STDMETHOD(Get)(THIS_ struct DEFFOLDERSETTINGS *buffer, int theSize) PURE;
|
STDMETHOD(Get)(THIS_ struct DEFFOLDERSETTINGS *pFDS, UINT cb) PURE;
|
||||||
STDMETHOD(Set)(THIS_ const struct DEFFOLDERSETTINGS *buffer, int theSize, unsigned int param14) PURE;
|
STDMETHOD(Set)(THIS_ const struct DEFFOLDERSETTINGS *pFDS, UINT cb, UINT unknown) PURE;
|
||||||
};
|
};
|
||||||
#undef INTERFACE
|
#undef INTERFACE
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue