[SHELL32][BROWSEUI] Implement ShellBrowser Apply/Reset default folder settings (#6912)

This commit is contained in:
Whindmar Saksit 2024-06-04 18:37:19 +02:00 committed by GitHub
parent ad73e17418
commit c97c1ad4c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 339 additions and 38 deletions

View file

@ -94,6 +94,36 @@ inline BOOL _ROS_FAILED_HELPER(HRESULT hr, const char* expr, const char* filenam
} /* extern "C" */
#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
template <typename T>
class CComCreatorCentralInstance

View file

@ -83,6 +83,12 @@ struct persistState
#define PANE_PRIVACY 7
#endif
/*****************************************************************************
* CGID_DefView OLECMD IDs
*/
#define DVCMDID_SET_DEFAULTFOLDER_SETTINGS 0
#define DVCMDID_RESET_DEFAULTFOLDER_SETTINGS 1
/*****************************************************************************
* IInitializeObject interface
*/
@ -144,7 +150,15 @@ DECLARE_INTERFACE_(IBanneredBar, IUnknown)//, "596A9A94-013E-11d1-8D34-00A0C90F2
*/
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
@ -152,12 +166,12 @@ struct DEFFOLDERSETTINGS
DECLARE_INTERFACE_(IGlobalFolderSettings, IUnknown)
{
/*** IUnknown ***/
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppv) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppv) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IGlobalFolderSettings ***/
STDMETHOD(Get)(THIS_ struct DEFFOLDERSETTINGS *buffer, int theSize) PURE;
STDMETHOD(Set)(THIS_ const struct DEFFOLDERSETTINGS *buffer, int theSize, unsigned int param14) PURE;
STDMETHOD(Get)(THIS_ struct DEFFOLDERSETTINGS *pFDS, UINT cb) PURE;
STDMETHOD(Set)(THIS_ const struct DEFFOLDERSETTINGS *pFDS, UINT cb, UINT unknown) PURE;
};
#undef INTERFACE