diff --git a/dll/win32/browseui/basebarsite.cpp b/dll/win32/browseui/basebarsite.cpp index 8d2675d996a..292d897e879 100644 --- a/dll/win32/browseui/basebarsite.cpp +++ b/dll/win32/browseui/basebarsite.cpp @@ -692,17 +692,10 @@ LRESULT CBaseBarSite::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bH LRESULT CBaseBarSite::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { - HRESULT hResult; - CComPtr parentSite; - if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDM_BASEBAR_CLOSE) { - hResult = fDeskBarSite->QueryInterface(IID_PPV_ARG(IDockingWindow, &parentSite)); - if (!SUCCEEDED(hResult)) - { - return E_FAIL; - } - parentSite->ShowDW(FALSE); + /* Tell the base bar to hide */ + IUnknown_Exec(fDeskBarSite, IID_IDeskBarClient, 0, 0, NULL, NULL); bHandled = TRUE; } return 0; diff --git a/dll/win32/browseui/internettoolbar.cpp b/dll/win32/browseui/internettoolbar.cpp index ca043486e5e..6ea5f07393a 100644 --- a/dll/win32/browseui/internettoolbar.cpp +++ b/dll/win32/browseui/internettoolbar.cpp @@ -749,6 +749,16 @@ HRESULT CInternetToolbar::LockUnlockToolbars(bool locked) return S_OK; } +HRESULT CInternetToolbar::SetState(const GUID *pguidCmdGroup, long commandID, OLECMD* pcmd) +{ + long state = 0; + if (pcmd->cmdf & OLECMDF_ENABLED) + state |= TBSTATE_ENABLED; + if (pcmd->cmdf & OLECMDF_LATCHED) + state |= TBSTATE_CHECKED; + return SetState(pguidCmdGroup, commandID, state); +} + HRESULT CInternetToolbar::CommandStateChanged(bool newValue, int commandID) { HRESULT hResult; @@ -762,6 +772,18 @@ HRESULT CInternetToolbar::CommandStateChanged(bool newValue, int commandID) // if up, QueryStatus for up state and update it // //for buttons in fCommandCategory, update with QueryStatus of fCommandTarget + + OLECMD commandList[4]; + commandList[0].cmdID = 0x1c; + commandList[1].cmdID = 0x1d; + commandList[2].cmdID = 0x1e; + commandList[3].cmdID = 0x23; + IUnknown_QueryStatus(fSite, CGID_Explorer, 4, commandList, NULL); + SetState(&CLSID_CommonButtons, gSearchCommandID, &commandList[0]); + SetState(&CLSID_CommonButtons, gFoldersCommandID, &commandList[3]); + //SetState(&CLSID_CommonButtons, gFavoritesCommandID, &commandList[2]); + //SetState(&CLSID_CommonButtons, gHistoryCommandID, &commandList[1]); + break; case 1: // forward @@ -1504,7 +1526,13 @@ LRESULT CInternetToolbar::OnUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BO LRESULT CInternetToolbar::OnSearch(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) { - return IUnknown_Exec(fSite, CLSID_CommonButtons, 0x123, 1, NULL, NULL); + OLECMD cmd; + cmd.cmdID = 0x1c; + IUnknown_QueryStatus(fSite, CGID_Explorer, 1, &cmd, NULL); + if (cmd.cmdf & OLECMDF_LATCHED) + return IUnknown_Exec(fSite, CGID_Explorer, 0x1c, 1, NULL, NULL); + else + return IUnknown_Exec(fSite, CLSID_CommonButtons, 0x123, 1, NULL, NULL); } LRESULT CInternetToolbar::OnFolders(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) @@ -1523,7 +1551,7 @@ LRESULT CInternetToolbar::OnForwardToCommandTarget(WORD wNotifyCode, WORD wID, H } return 1; } - + LRESULT CInternetToolbar::OnMenuDropDown(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled) { CComPtr browserService; diff --git a/dll/win32/browseui/internettoolbar.h b/dll/win32/browseui/internettoolbar.h index 0c47019b984..e824df72b19 100644 --- a/dll/win32/browseui/internettoolbar.h +++ b/dll/win32/browseui/internettoolbar.h @@ -104,6 +104,7 @@ public: HRESULT CreateAndInitBandProxy(); HRESULT IsBandVisible(int BandID); HRESULT ToggleBandVisibility(int BandID); + HRESULT SetState(const GUID *pguidCmdGroup, long commandID, OLECMD* pcmd); public: // *** IInputObject specific methods *** diff --git a/dll/win32/browseui/shellbars/CBaseBar.cpp b/dll/win32/browseui/shellbars/CBaseBar.cpp index 44d2ec5d158..ebc3d06f7b3 100644 --- a/dll/win32/browseui/shellbars/CBaseBar.cpp +++ b/dll/win32/browseui/shellbars/CBaseBar.cpp @@ -261,8 +261,17 @@ HRESULT STDMETHODCALLTYPE CBaseBar::Exec(const GUID *pguidCmdGroup, DWORD nCmdID switch (nCmdID) { case 0: + { // hide current band + ShowDW(0); + + // Inform our site that we closed + VARIANT var; + V_VT(&var) = VT_UNKNOWN; + V_UNKNOWN(&var) = static_cast(this); + IUnknown_Exec(fSite, CGID_Explorer, 0x22, 0, &var, NULL); break; + } case 2: // switch bands break; diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp index 5345ef32858..b1d39028506 100644 --- a/dll/win32/browseui/shellbrowser.cpp +++ b/dll/win32/browseui/shellbrowser.cpp @@ -299,6 +299,7 @@ private: CComPtr 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. IOleObject *fHistoryObject; @@ -1276,6 +1277,12 @@ HRESULT CShellBrowser::ShowBand(const CLSID &classID, bool vertical) if (FAILED_UNEXPECTEDLY(hResult)) return hResult; + if (vertical) + { + fCurrentVertBar = classID; + FireCommandStateChangeAll(); + } + return S_OK; } @@ -1939,15 +1946,28 @@ HRESULT STDMETHODCALLTYPE CShellBrowser::QueryStatus(const GUID *pguidCmdGroup, { case 0x1c: // search prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED; + if (IsEqualCLSID(CLSID_SH_SearchBand, fCurrentVertBar) || + IsEqualCLSID(CLSID_SearchBand, fCurrentVertBar) || + IsEqualCLSID(CLSID_IE_SearchBand, fCurrentVertBar) || + IsEqualCLSID(CLSID_FileSearchBand, fCurrentVertBar)) + { + prgCmds->cmdf |= OLECMDF_LATCHED; + } break; case 0x1d: // history prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED; + if (IsEqualCLSID(CLSID_SH_HistBand, fCurrentVertBar)) + prgCmds->cmdf |= OLECMDF_LATCHED; break; case 0x1e: // favorites prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED; + if (IsEqualCLSID(CLSID_SH_FavBand, fCurrentVertBar)) + prgCmds->cmdf |= OLECMDF_LATCHED; break; case 0x23: // folders - prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED | OLECMDF_LATCHED; + prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED; + if (IsEqualCLSID(CLSID_ExplorerBand, fCurrentVertBar)) + prgCmds->cmdf |= OLECMDF_LATCHED; break; default: prgCmds->cmdf = 0; @@ -1990,8 +2010,46 @@ HRESULT STDMETHODCALLTYPE CShellBrowser::Exec(const GUID *pguidCmdGroup, DWORD n { switch (nCmdID) { - case 0x23: - hResult = ShowBand(CLSID_ExplorerBand, true); + case 0x1c: //Toggle Search + if (IsEqualCLSID(CLSID_SH_SearchBand, fCurrentVertBar) || + IsEqualCLSID(CLSID_SearchBand, fCurrentVertBar) || + IsEqualCLSID(CLSID_IE_SearchBand, fCurrentVertBar) || + IsEqualCLSID(CLSID_FileSearchBand, fCurrentVertBar)) + { + hResult = IUnknown_ShowDW(fClientBars[BIVerticalBaseBar].clientBar.p, FALSE); + memset(&fCurrentVertBar, 0, sizeof(fCurrentVertBar)); + FireCommandStateChangeAll(); + } + return S_OK; + case 0x1d: //Toggle History + case 0x1e: //Toggle Favorites + case 0x23: //Toggle Folders + const GUID* pclsid; + if (nCmdID == 0x1d) pclsid = &CLSID_SH_HistBand; + else if (nCmdID == 0x1e) pclsid = &CLSID_SH_FavBand; + else pclsid = &CLSID_ExplorerBand; + + if (IsEqualCLSID(*pclsid, fCurrentVertBar)) + { + hResult = IUnknown_ShowDW(fClientBars[BIVerticalBaseBar].clientBar.p, FALSE); + memset(&fCurrentVertBar, 0, sizeof(fCurrentVertBar)); + FireCommandStateChangeAll(); + } + else + { + hResult = ShowBand(*pclsid, true); + } + return S_OK; + case 0x22: + //Sent when a band closes + if (V_VT(pvaIn) != VT_UNKNOWN) + return E_INVALIDARG; + + if (IUnknownIsEqual(V_UNKNOWN(pvaIn), fClientBars[BIVerticalBaseBar].clientBar.p)) + { + memset(&fCurrentVertBar, 0, sizeof(fCurrentVertBar)); + FireCommandStateChangeAll(); + } return S_OK; case 0x27: if (nCmdexecopt == 1)