https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5af47c9bafe09b123df40c83d78e91438633bb00

commit 5af47c9bafe09b123df40c83d78e91438633bb00
Author:     Whindmar Saksit <whinds...@proton.me>
AuthorDate: Sun Mar 9 21:59:03 2025 +0100
Commit:     GitHub <nore...@github.com>
CommitDate: Sun Mar 9 21:59:03 2025 +0100

    [BROWSEUI] Set AddressBand Go button checkbox state correctly in menu 
(#7771)
    
    CORE-20018
---
 dll/win32/browseui/addressband.cpp     | 23 +++++++++++++++++++++--
 dll/win32/browseui/addressband.h       |  3 +++
 dll/win32/browseui/internettoolbar.cpp | 13 +++++++++++++
 dll/win32/browseui/internettoolbar.h   |  1 +
 dll/win32/browseui/settings.cpp        |  3 +--
 dll/win32/browseui/shellbrowser.cpp    | 10 ++++------
 6 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/dll/win32/browseui/addressband.cpp 
b/dll/win32/browseui/addressband.cpp
index 25b038655e0..51a80735ec1 100644
--- a/dll/win32/browseui/addressband.cpp
+++ b/dll/win32/browseui/addressband.cpp
@@ -37,6 +37,9 @@ TODO:
     Implement Save
 */
 
+// Unique GUID of the DLL where this CAddressBand is implemented so we can 
tell if it's really us
+static const GUID THISMODULE_GUID = { 0x60ebab6e, 0x2e4b, 0x42f6, { 
0x8a,0xbc,0x80,0x73,0x1c,0xa6,0x42,0x02} };
+
 CAddressBand::CAddressBand()
 {
     fEditControl = NULL;
@@ -49,6 +52,20 @@ CAddressBand::~CAddressBand()
 {
 }
 
+BOOL CAddressBand::ShouldShowGoButton()
+{
+    return SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet 
Explorer\\Main", L"ShowGoButton", FALSE, TRUE);
+}
+
+BOOL CAddressBand::IsGoButtonVisible(IUnknown *pUnkBand)
+{
+    CComPtr<IAddressBand> pAB;
+    IUnknown_QueryService(pUnkBand, THISMODULE_GUID, IID_PPV_ARG(IAddressBand, 
&pAB));
+    if (pAB)
+        return static_cast<CAddressBand*>(pAB.p)->fGoButtonShown;
+    return ShouldShowGoButton(); // We don't know, return the global state
+}
+
 void CAddressBand::FocusChange(BOOL bFocus)
 {
 //    m_bFocus = bFocus;
@@ -168,7 +185,7 @@ HRESULT STDMETHODCALLTYPE CAddressBand::SetSite(IUnknown 
*pUnkSite)
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
 
-    fGoButtonShown = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet 
Explorer\\Main", L"ShowGoButton", FALSE, TRUE);
+    fGoButtonShown = ShouldShowGoButton();
     if (fGoButtonShown)
         CreateGoButton();
 
@@ -365,7 +382,7 @@ HRESULT STDMETHODCALLTYPE CAddressBand::OnWinEvent(
         case WM_COMMAND:
             if (wParam == IDM_TOOLBARS_GOBUTTON)
             {
-                fGoButtonShown = 
!SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main", 
L"ShowGoButton", FALSE, TRUE);
+                fGoButtonShown = 
!IsGoButtonVisible(static_cast<IAddressBand*>(this));
                 SHRegSetUSValueW(L"Software\\Microsoft\\Internet 
Explorer\\Main", L"ShowGoButton", REG_SZ, fGoButtonShown ? (LPVOID)L"yes" : 
(LPVOID)L"no", fGoButtonShown ? 8 : 6, SHREGSET_FORCE_HKCU);
                 if (!fGoButton)
                     CreateGoButton();
@@ -421,6 +438,8 @@ HRESULT STDMETHODCALLTYPE CAddressBand::Refresh(long param8)
 
 HRESULT STDMETHODCALLTYPE CAddressBand::QueryService(REFGUID guidService, 
REFIID riid, void **ppvObject)
 {
+    if (guidService == THISMODULE_GUID)
+        return QueryInterface(riid, ppvObject);
     return E_NOTIMPL;
 }
 
diff --git a/dll/win32/browseui/addressband.h b/dll/win32/browseui/addressband.h
index 1ffa7cea0d8..52986f1d782 100644
--- a/dll/win32/browseui/addressband.h
+++ b/dll/win32/browseui/addressband.h
@@ -51,6 +51,9 @@ private:
     void FocusChange(BOOL bFocus);
     void CreateGoButton();
 public:
+    static BOOL ShouldShowGoButton();
+    static BOOL IsGoButtonVisible(IUnknown *pUnkBand);
+
     // *** IDeskBand methods ***
     STDMETHOD(GetBandInfo)(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO 
*pdbi) override;
 
diff --git a/dll/win32/browseui/internettoolbar.cpp 
b/dll/win32/browseui/internettoolbar.cpp
index 2ff27b6a2cb..3ab130dc5cd 100644
--- a/dll/win32/browseui/internettoolbar.cpp
+++ b/dll/win32/browseui/internettoolbar.cpp
@@ -658,6 +658,16 @@ HRESULT CInternetToolbar::EnumBands(UINT Index, int 
*pBandId, IUnknown **ppUnkBa
     return *ppUnkBand ? S_OK : S_FALSE;
 }
 
+HRESULT CInternetToolbar::QIBand(int BandID, REFIID riid, void **ppv)
+{
+    IUnknown *pUnk; // Not ref. counted
+    int temp = (UINT) SendMessageW(fMainReBar, RB_IDTOINDEX, BandID, 0);
+    if (EnumBands(temp, &temp, &pUnk) == S_OK)
+        return pUnk->QueryInterface(riid, ppv);
+    *ppv = NULL;
+    return E_NOINTERFACE;
+}
+
 HRESULT CInternetToolbar::ReserveBorderSpace(LONG maxHeight)
 {
     CComPtr<IDockingWindowSite>             dockingWindowSite;
@@ -1746,6 +1756,7 @@ LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM 
wParam, LPARAM lParam,
     RBHITTESTINFO                           hitTestInfo;
     REBARBANDINFOW                          rebarBandInfo;
     int                                     bandID;
+    CComPtr<IAddressBand>                   pAddress;
 
     clickLocation.x = LOWORD(lParam);
     clickLocation.y = HIWORD(lParam);
@@ -1780,6 +1791,8 @@ LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM 
wParam, LPARAM lParam,
         case ITBBID_ADDRESSBAND:    // navigation band
             DeleteMenu(contextMenu, IDM_TOOLBARS_CUSTOMIZE, MF_BYCOMMAND);
             DeleteMenu(contextMenu, IDM_TOOLBARS_TEXTLABELS, MF_BYCOMMAND);
+            QIBand(ITBBID_ADDRESSBAND, IID_PPV_ARG(IAddressBand, &pAddress));
+            pSettings->fShowGoButton = 
CAddressBand::IsGoButtonVisible(pAddress);
             break;
         default:
             break;
diff --git a/dll/win32/browseui/internettoolbar.h 
b/dll/win32/browseui/internettoolbar.h
index 7e97608c484..b1e93501e25 100644
--- a/dll/win32/browseui/internettoolbar.h
+++ b/dll/win32/browseui/internettoolbar.h
@@ -103,6 +103,7 @@ public:
     virtual ~CInternetToolbar();
     void AddDockItem(IUnknown *newItem, int bandID, int flags);
     HRESULT EnumBands(UINT Index, int *pBandId, IUnknown **ppUnkBand);
+    HRESULT QIBand(int BandID, REFIID riid, void **ppv);
     HRESULT ReserveBorderSpace(LONG maxHeight = -1);
     HRESULT CreateMenuBar(IShellMenu **menuBar);
     HRESULT CreateToolsBar(IUnknown **toolsBar);
diff --git a/dll/win32/browseui/settings.cpp b/dll/win32/browseui/settings.cpp
index 89fb28f3666..ceb7a4e91f5 100644
--- a/dll/win32/browseui/settings.cpp
+++ b/dll/win32/browseui/settings.cpp
@@ -26,8 +26,7 @@ void ShellSettings::Load()
     fStatusBarVisible = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet 
Explorer\\Main",
                                              L"StatusBarOther", FALSE, TRUE);
 
-    fShowGoButton = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet 
Explorer\\Main",
-                                         L"ShowGoButton", FALSE, TRUE);
+    fShowGoButton = CAddressBand::ShouldShowGoButton();
 
     fLocked = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet 
Explorer\\Toolbar",
                                    L"Locked", FALSE, TRUE);
diff --git a/dll/win32/browseui/shellbrowser.cpp 
b/dll/win32/browseui/shellbrowser.cpp
index cd729c02998..bd58da36ab0 100644
--- a/dll/win32/browseui/shellbrowser.cpp
+++ b/dll/win32/browseui/shellbrowser.cpp
@@ -1196,11 +1196,8 @@ HRESULT CShellBrowser::GetMenuBand(REFIID riid, void 
**shellMenu)
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
 
-    hResult = bandSite->QueryBand(1, &deskBand, NULL, NULL, 0);
-    if (FAILED_UNEXPECTEDLY(hResult))
-        return hResult;
-
-    return deskBand->QueryInterface(riid, shellMenu);
+    hResult = bandSite->QueryBand(ITBBID_MENUBAND, &deskBand, NULL, NULL, 0);
+    return FAILED(hResult) ? hResult : deskBand->QueryInterface(riid, 
shellMenu); // It is expected that this might fail during WM_DESTROY
 }
 
 HRESULT CShellBrowser::GetBaseBar(bool vertical, REFIID riid, void 
**theBaseBar)
@@ -2097,7 +2094,7 @@ HRESULT STDMETHODCALLTYPE 
CShellBrowser::QueryStatus(const GUID *pguidCmdGroup,
             {
                 case IDM_GOTO_UPONELEVEL:
                     prgCmds->cmdf = OLECMDF_SUPPORTED;
-                    if (fCurrentDirectoryPIDL->mkid.cb != 0)
+                    if (!_ILIsDesktop(fCurrentDirectoryPIDL))
                         prgCmds->cmdf |= OLECMDF_ENABLED;
                     break;
             }
@@ -3696,6 +3693,7 @@ LRESULT CShellBrowser::OnDestroy(UINT uMsg, WPARAM 
wParam, LPARAM lParam, BOOL &
 
         fCurrentShellFolder.Release();
         ILFree(fCurrentDirectoryPIDL);
+        fCurrentDirectoryPIDL = NULL;
         ::DestroyWindow(fStatusBar);
         DestroyMenu(fCurrentMenuBar);
     }

Reply via email to