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.
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;
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;
// 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
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)
}
return 1;
}
-
+
LRESULT CInternetToolbar::OnMenuDropDown(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled)
{
CComPtr<IBrowserService> browserService;
HRESULT CreateAndInitBandProxy();
HRESULT IsBandVisible(int BandID);
HRESULT ToggleBandVisibility(int BandID);
+ HRESULT SetState(const GUID *pguidCmdGroup, long commandID, OLECMD* pcmd);
public:
// *** IInputObject specific methods ***
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;
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;
if (FAILED_UNEXPECTEDLY(hResult))
return hResult;
+ if (vertical)
+ {
+ fCurrentVertBar = classID;
+ FireCommandStateChangeAll();
+ }
+
return S_OK;
}
{
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;
{
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)