[BROWSEUI] Set AddressBand Go button checkbox state correctly in menu (#7771)

CORE-20018
This commit is contained in:
Whindmar Saksit 2025-03-09 21:59:03 +01:00 committed by GitHub
parent 5461abeeba
commit 5af47c9baf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 43 additions and 10 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);
}