https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a0c5cafce58dfd8d248fb…
commit a0c5cafce58dfd8d248fb596bf816ed754c4280f
Author: Giannis Adamopoulos <gadamopoulos(a)reactos.org>
AuthorDate: Sat Oct 27 11:52:04 2018 +0300
Commit: Giannis Adamopoulos <gadamopoulos(a)reactos.org>
CommitDate: Sat Oct 27 15:08:24 2018 +0300
[BROWSEUI] Implement toggling the folders and search band with the toolbar and make
their buttons appear pressed when they are shown.
CBaseBarSite: Ask the CBaseBar to close itself when the x button is pressed.
CBaseBar: Hide the bar and inform its site that it is closing when it gets the close
command.
CShellBrowser: Cache the guid of the current vertical bar and use it to report correct
command status to the toolbar.
Also implement toggling the Folders, Favorites, History and search commands.
CInternetToolbar: Query the Folders and Search command status from the site so that
they can be properly be shown as pressed.
---
dll/win32/browseui/basebarsite.cpp | 11 +-----
dll/win32/browseui/internettoolbar.cpp | 32 +++++++++++++++-
dll/win32/browseui/internettoolbar.h | 1 +
dll/win32/browseui/shellbars/CBaseBar.cpp | 9 +++++
dll/win32/browseui/shellbrowser.cpp | 64 +++++++++++++++++++++++++++++--
5 files changed, 103 insertions(+), 14 deletions(-)
diff --git a/dll/win32/browseui/basebarsite.cpp b/dll/win32/browseui/basebarsite.cpp
index 8d2675d996..292d897e87 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<IDockingWindow> 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 ca043486e5..6ea5f07393 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<IBrowserService> browserService;
diff --git a/dll/win32/browseui/internettoolbar.h b/dll/win32/browseui/internettoolbar.h
index 0c47019b98..e824df72b1 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 44d2ec5d15..ebc3d06f7b 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<IDeskBar *>(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 5345ef3285..b1d3902850 100644
--- a/dll/win32/browseui/shellbrowser.cpp
+++ b/dll/win32/browseui/shellbrowser.cpp
@@ -299,6 +299,7 @@ private:
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.
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)