https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f744bb29946167810a81c…
commit f744bb29946167810a81c093bad6d4e5bf6bdf8a
Author: Carl J. Bialorucki <cbialo2(a)outlook.com>
AuthorDate: Mon Oct 2 14:43:00 2023 -0600
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Oct 2 22:43:00 2023 +0200
[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
---
boot/bootdata/hivedef.inf | 1 +
dll/win32/browseui/addresseditbox.cpp | 22 ++++-----
dll/win32/browseui/addresseditbox.h | 2 +
dll/win32/browseui/browseui.h | 1 +
dll/win32/browseui/precomp.h | 15 +-----
dll/win32/browseui/settings.cpp | 20 ++++++--
dll/win32/browseui/settings.h | 30 ++++++++++++
dll/win32/browseui/shellbrowser.cpp | 90 +++++++++++++++++------------------
8 files changed, 104 insertions(+), 77 deletions(-)
diff --git a/boot/bootdata/hivedef.inf b/boot/bootdata/hivedef.inf
index 6551f5a7701..57b7ea8d2f0 100644
--- a/boot/bootdata/hivedef.inf
+++ b/boot/bootdata/hivedef.inf
@@ -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
diff --git a/dll/win32/browseui/addresseditbox.cpp
b/dll/win32/browseui/addresseditbox.cpp
index 6051b43fb5b..cec978c191e 100644
--- a/dll/win32/browseui/addresseditbox.cpp
+++ b/dll/win32/browseui/addresseditbox.cpp
@@ -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;
+}
diff --git a/dll/win32/browseui/addresseditbox.h b/dll/win32/browseui/addresseditbox.h
index 336f38ff0c9..beb043e1e1e 100644
--- a/dll/win32/browseui/addresseditbox.h
+++ b/dll/win32/browseui/addresseditbox.h
@@ -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)
diff --git a/dll/win32/browseui/browseui.h b/dll/win32/browseui/browseui.h
index 02d75a25e16..46907ad0ad7 100644
--- a/dll/win32/browseui/browseui.h
+++ b/dll/win32/browseui/browseui.h
@@ -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);
diff --git a/dll/win32/browseui/precomp.h b/dll/win32/browseui/precomp.h
index c3c26e7115d..cfed44eef59 100644
--- a/dll/win32/browseui/precomp.h
+++ b/dll/win32/browseui/precomp.h
@@ -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_ */
diff --git a/dll/win32/browseui/settings.cpp b/dll/win32/browseui/settings.cpp
index de7e6c04480..65af70c950e 100644
--- a/dll/win32/browseui/settings.cpp
+++ b/dll/win32/browseui/settings.cpp
@@ -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);
+}
+
+void CabinetStateSettings::Load()
+{
+ ReadCabinetState(this, this->cLength);
+
+ /* Overrides */
+ fFullPathTitle =
SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState",
+ L"FullPath", FALSE, FALSE);
- return TRUE;
+ fFullPathAddress =
SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState",
+ L"FullPathAddress", FALSE, TRUE);
}
diff --git a/dll/win32/browseui/settings.h b/dll/win32/browseui/settings.h
new file mode 100644
index 00000000000..38e58c1fe99
--- /dev/null
+++ b/dll/win32/browseui/settings.h
@@ -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(a)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;
diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp
index 9c8edff1822..114d6c59553 100644
--- a/dll/win32/browseui/shellbrowser.cpp
+++ b/dll/win32/browseui/shellbrowser.cpp
@@ -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);
- if (SUCCEEDED(hResult))
- {
- SetWindowText(newTitle);
+ UpdateWindowTitle();
- LPCITEMIDLIST pidlChild;
- INT index, indexOpen;
- HIMAGELIST himlSmall, himlLarge;
+ LPCITEMIDLIST pidlChild;
+ INT index, indexOpen;
+ HIMAGELIST himlSmall, himlLarge;
- CComPtr<IShellFolder> sf;
- hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf),
&pidlChild);
- if (SUCCEEDED(hResult))
- {
- index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
+ CComPtr<IShellFolder> sf;
+ hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf),
&pidlChild);
+ if (SUCCEEDED(hResult))
+ {
+ index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
- Shell_GetImageLists(&himlLarge, &himlSmall);
+ Shell_GetImageLists(&himlLarge, &himlSmall);
- HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
- HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
+ HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
+ HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
- /* 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);
+ /* 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));
+ 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);
+}