[BROWSEUI] More settings and window refresh (#5584)

Adds the option to set the address edit box to use the display name or the full path. Also refreshes the window title and edit box in all open explorer windows when changing these settings using the folder options dialog.

## PROPOSED CHANGES ##
- Create a new CabinetStateSettings type that inherits from the CABINETSTATE type. This allows us to add additional cabinet state settings not exposed in the CABINETSTATE type as well as adding a Load() method to easily populate the cabinet state settings.

- Add a global cabinet state settings object. While most settings in browseui are stored independently in each shellbrowser window, cabinet state settings are global and apply to every shellbrowser window. This can be confirmed on Windows Server 2003 and Windows 7.

- When receiving the WM_SETTINGCHANGE window message from the folder options dialog, refresh the title of the window and the text in the address edit box. This is the same behavior as Windows Server 2003 and Windows 7.
Add a DWORD registry value to HKCU\...\Explorer\CabinetState\FullPathAddress to allow users to toggle this setting on or off in our folder options.

CORE-9277
This commit is contained in:
Carl J. Bialorucki 2023-10-02 14:43:00 -06:00 committed by GitHub
parent 1aa76275ac
commit f744bb2994
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 105 additions and 78 deletions

View file

@ -1901,6 +1901,7 @@ HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","Hidden",0x00
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","ShowSuperHidden",0x00010003,0
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CabinetState",,0x00000012
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CabinetState","FullPath",0x00010003,0
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CabinetState","FullPathAddress",0x00010003,1
HKCU,"SOFTWARE\Microsoft\Internet Explorer\Main","StatusBarOther",0x00010003,1
HKCU,"SOFTWARE\Microsoft\Internet Explorer\Toolbar","Locked",0x00010003,1

View file

@ -130,18 +130,12 @@ HRESULT CAddressEditBox::RefreshAddress()
/* Set the path if filesystem; otherwise use the name */
WCHAR szPathOrName[MAX_PATH];
if (!SHGetPathFromIDListW(absolutePIDL, szPathOrName))
{
STRRET ret;
hr = pShellFolder->GetDisplayNameOf(pidlChild, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING, &ret);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
SHGDNF flags = SHGDN_FORADDRESSBAR;
if (gCabinetState.fFullPathAddress)
flags |= SHGDN_FORPARSING;
hr = StrRetToBufW(&ret, pidlChild, szPathOrName, _countof(szPathOrName));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
}
item.pszText = szPathOrName;
if (SUCCEEDED(IEGetNameAndFlags(absolutePIDL, flags, szPathOrName, _countof(szPathOrName), NULL)))
item.pszText = szPathOrName;
/* Ownership of absolutePIDL will be moved to fCombobox. See CBEN_DELETEITEM */
item.lParam = reinterpret_cast<LPARAM>(absolutePIDL.Detach());
@ -644,3 +638,9 @@ LPITEMIDLIST CAddressEditBox::GetItemData(int index)
SendMessageW(hComboBoxEx, CBEM_GETITEMW, 0, (LPARAM)&item);
return (LPITEMIDLIST)item.lParam;
}
LRESULT CAddressEditBox::OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
RefreshAddress();
return NO_ERROR;
}

View file

@ -91,6 +91,7 @@ public:
virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
// message handlers
LRESULT OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
DECLARE_REGISTRY_RESOURCEID(IDR_ADDRESSEDITBOX)
DECLARE_NOT_AGGREGATABLE(CAddressEditBox)
@ -98,6 +99,7 @@ public:
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_MSG_MAP(CAddressEditBox)
MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
END_MSG_MAP()
BEGIN_COM_MAP(CAddressEditBox)

View file

@ -24,3 +24,4 @@ HRESULT CTravelLog_CreateInstance(REFIID riid, void **ppv);
HRESULT CBaseBar_CreateInstance(REFIID riid, void **ppv, BOOL vertical);
HRESULT CBaseBarSite_CreateInstance(REFIID riid, void **ppv, BOOL bVertical);
HRESULT CToolsBand_CreateInstance(REFIID riid, void **ppv);
HRESULT IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut);

View file

@ -36,10 +36,7 @@
#include <wine/debug.h>
#include "resource.h"
#define BWM_SETTINGCHANGE (WM_USER + 300)
#define BWM_GETSETTINGSPTR (WM_USER + 301)
struct ShellSettings;
#include "settings.h"
#include "ACLCustomMRU.h"
#include "aclhistory.h"
@ -69,14 +66,4 @@ struct ShellSettings;
WINE_DEFAULT_DEBUG_CHANNEL(browseui);
struct ShellSettings
{
BOOL fLocked = FALSE;
BOOL fShowGoButton = FALSE;
BOOL fStatusBarVisible = FALSE;
BOOL Save();
BOOL Load();
};
#endif /* _BROWSEUI_PCH_ */

View file

@ -7,7 +7,9 @@
#include "precomp.h"
BOOL ShellSettings::Save()
CabinetStateSettings gCabinetState;
void ShellSettings::Save()
{
SHRegSetUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main", L"StatusBarOther",
REG_DWORD, &fStatusBarVisible, sizeof(fStatusBarVisible), SHREGSET_FORCE_HKCU);
@ -17,11 +19,9 @@ BOOL ShellSettings::Save()
SHRegSetUSValueW(L"Software\\Microsoft\\Internet Explorer\\Toolbar", L"Locked",
REG_DWORD, &fLocked, sizeof(fLocked), SHREGSET_FORCE_HKCU);
return TRUE;
}
BOOL ShellSettings::Load()
void ShellSettings::Load()
{
fStatusBarVisible = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main",
L"StatusBarOther", FALSE, FALSE);
@ -31,6 +31,16 @@ BOOL ShellSettings::Load()
fLocked = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Toolbar",
L"Locked", FALSE, TRUE);
return TRUE;
}
void CabinetStateSettings::Load()
{
ReadCabinetState(this, this->cLength);
/* Overrides */
fFullPathTitle = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState",
L"FullPath", FALSE, FALSE);
fFullPathAddress = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState",
L"FullPathAddress", FALSE, TRUE);
}

View file

@ -0,0 +1,30 @@
/*
* PROJECT: ReactOS browseui
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Settings header file
* COPYRIGHT: Copyright 2023 Carl Bialorucki <cbialo2@outlook.com>
*/
#include "precomp.h"
#define BWM_SETTINGCHANGE (WM_USER + 300)
#define BWM_GETSETTINGSPTR (WM_USER + 301)
struct ShellSettings
{
BOOL fLocked = FALSE;
BOOL fShowGoButton = FALSE;
BOOL fStatusBarVisible = FALSE;
void Save();
void Load();
};
struct CabinetStateSettings : CABINETSTATE
{
BOOL fFullPathAddress = TRUE;
void Load();
};
extern CabinetStateSettings gCabinetState;

View file

@ -296,7 +296,6 @@ private:
barInfo fClientBars[3];
CComPtr<ITravelLog> fTravelLog;
HMENU fCurrentMenuBar;
CABINETSTATE fCabinetState;
GUID fCurrentVertBar; //The guid of the built in vertical bar that is being shown
// The next three fields support persisted history for shell views.
// They do not need to be reference counted.
@ -350,7 +349,8 @@ public:
HRESULT UpdateUpState();
void UpdateGotoMenu(HMENU theMenu);
void UpdateViewMenu(HMENU theMenu);
void LoadCabinetState();
void RefreshCabinetState();
void UpdateWindowTitle();
/* // *** IDockingWindowFrame methods ***
virtual HRESULT STDMETHODCALLTYPE AddToolbar(IUnknown *punkSrc, LPCWSTR pwszItem, DWORD dwAddFlags);
@ -721,6 +721,7 @@ CShellBrowser::CShellBrowser()
fHistoryStream = NULL;
fHistoryBindContext = NULL;
m_settings.Load();
gCabinetState.Load();
}
CShellBrowser::~CShellBrowser()
@ -741,11 +742,6 @@ HRESULT CShellBrowser::Initialize()
if (!menuDsa)
return E_OUTOFMEMORY;
fCabinetState.cLength = sizeof(fCabinetState);
if (ReadCabinetState(&fCabinetState, sizeof(fCabinetState)) == FALSE)
{
}
// create window
Create(HWND_DESKTOP);
if (m_hWnd == NULL)
@ -790,8 +786,6 @@ HRESULT CShellBrowser::Initialize()
fToolbarProxy.Initialize(m_hWnd, clientBar);
LoadCabinetState();
// create status bar
DWORD dwStatusStyle = WS_CHILD | WS_CLIPSIBLINGS | SBARS_SIZEGRIP | SBARS_TOOLTIPS;
if (m_settings.fStatusBarVisible)
@ -923,7 +917,7 @@ cleanup:
return hResult;
}
long IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
HRESULT IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
{
return IEGetNameAndFlagsEx(pidl, uFlags, 0, pszBuf, cchBuf, rgfInOut);
}
@ -1051,42 +1045,33 @@ HRESULT CShellBrowser::BrowseToPath(IShellFolder *newShellFolder,
FireNavigateComplete(L"ERROR");
}
if (fCabinetState.fFullPathTitle)
nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
else
nameFlags = SHGDN_FORADDRESSBAR;
hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
sizeof(newTitle) / sizeof(wchar_t), NULL);
UpdateWindowTitle();
LPCITEMIDLIST pidlChild;
INT index, indexOpen;
HIMAGELIST himlSmall, himlLarge;
CComPtr<IShellFolder> sf;
hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
if (SUCCEEDED(hResult))
{
SetWindowText(newTitle);
index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
LPCITEMIDLIST pidlChild;
INT index, indexOpen;
HIMAGELIST himlSmall, himlLarge;
Shell_GetImageLists(&himlLarge, &himlSmall);
CComPtr<IShellFolder> sf;
hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
if (SUCCEEDED(hResult))
{
index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
Shell_GetImageLists(&himlLarge, &himlSmall);
/* Hack to make it possible to release the old icons */
/* Something seems to go wrong with WM_SETICON */
HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0);
HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icLarge));
/* Hack to make it possible to release the old icons */
/* Something seems to go wrong with WM_SETICON */
HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0);
SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icLarge));
DestroyIcon(oldSmall);
DestroyIcon(oldLarge);
}
DestroyIcon(oldSmall);
DestroyIcon(oldLarge);
}
FireCommandStateChangeAll();
@ -1524,14 +1509,6 @@ void CShellBrowser::RepositionBars()
clientRect.bottom - clientRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
}
void CShellBrowser::LoadCabinetState()
{
fCabinetState.fFullPathTitle = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState",
L"FullPath",
FALSE,
FALSE);
}
HRESULT CShellBrowser::FireEvent(DISPID dispIdMember, int argCount, VARIANT *arguments)
{
DISPPARAMS params;
@ -3600,6 +3577,7 @@ LRESULT CShellBrowser::RelayMsgToShellView(UINT uMsg, WPARAM wParam, LPARAM lPar
LRESULT CShellBrowser::OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
RefreshCabinetState();
SHPropagateMessage(m_hWnd, uMsg, wParam, lParam, TRUE);
return 0;
}
@ -3860,3 +3838,21 @@ HRESULT CShellBrowser_CreateInstance(REFIID riid, void **ppv)
{
return ShellObjectCreatorInit<CShellBrowser>(riid, ppv);
}
void CShellBrowser::RefreshCabinetState()
{
gCabinetState.Load();
UpdateWindowTitle();
}
void CShellBrowser::UpdateWindowTitle()
{
WCHAR title[MAX_PATH];
SHGDNF flags = SHGDN_FORADDRESSBAR;
if (gCabinetState.fFullPathTitle)
flags |= SHGDN_FORPARSING;
if (SUCCEEDED(IEGetNameAndFlags(fCurrentDirectoryPIDL, flags, title, _countof(title), NULL)))
SetWindowText(title);
}