Implements a class that knows how to hold and manage the menu band, brand band,
toolbar, and address band for an explorer window
*/
+
#include "precomp.h"
+#define USE_CUSTOM_MENUBAND 1
+
// navigation controls and menubar just send a message to parent window
/*
TODO:
extern HRESULT CreateBandProxy(REFIID riid, void **ppv);
extern HRESULT CreateAddressBand(REFIID riid, void **ppv);
+typedef HRESULT(*PMENUBAND_CONSTRUCTOR)(REFIID riid, void **ppv);
+
class CInternetToolbar;
class CDockSite :
HRESULT STDMETHODCALLTYPE CDockSite::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
{
- CComPtr<IServiceProvider> serviceProvider;
- HRESULT hResult;
-
if (IsEqualIID(guidService, SID_SMenuBandParent))
return this->QueryInterface(riid, ppvObject);
- hResult = fToolbar->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
- if (FAILED(hResult))
- return hResult;
- return serviceProvider->QueryService(guidService, riid, ppvObject);
+
+ return fToolbar->QueryService(guidService, riid, ppvObject);
}
CMenuCallback::CMenuCallback()
favoritesHMenu = GetSubMenu(parentHMenu, 3);
if (favoritesHMenu == NULL)
return E_FAIL;
+#if USE_CUSTOM_MENUBAND
+ HMODULE hrs = LoadLibrary(L"rshell.dll");
+
+ PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
+ if (func)
+ {
+ hResult = func(IID_PPV_ARG(IShellMenu, &newMenu));
+ }
+ else
+ {
+ hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
+ IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
+ }
+#else
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
+#endif
if (FAILED(hResult))
return hResult;
hResult = newMenu->Initialize(this, FCIDM_MENU_FAVORITES, -1, SMINIT_VERTICAL | SMINIT_CACHED);
HWND ownerWindow;
HRESULT hResult;
+#if USE_CUSTOM_MENUBAND
+ HMODULE hrs = LoadLibraryW(L"rshell.dll");
+
+ if (!hrs)
+ {
+ DbgPrint("Failed: %d\n", GetLastError());
+ return E_FAIL;
+ }
+
+ PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
+ if (func)
+ {
+ hResult = func(IID_PPV_ARG(IShellMenu, menuBar));
+ }
+ else
+ {
+ DbgPrint("Failed: %d\n", GetLastError());
+ hResult = E_FAIL;
+ }
+
+ if (FAILED(hResult))
+ {
+ hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
+ IID_IShellMenu, reinterpret_cast<void **>(menuBar));
+ }
+#else
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
IID_IShellMenu, reinterpret_cast<void **>(menuBar));
+#endif
if (FAILED(hResult))
return hResult;
hResult = fMenuCallback.QueryInterface(IID_IShellMenuCallback, reinterpret_cast<void **>(&callback));
HRESULT STDMETHODCALLTYPE CInternetToolbar::InitNew()
{
CComPtr<IShellMenu> menuBar;
- CComPtr<IUnknown> logoBar;
+ //CComPtr<IUnknown> logoBar;
CComPtr<IUnknown> toolsBar;
CComPtr<IUnknown> navigationBar;
CComPtr<IOleWindow> menuOleWindow;
hResult = menuOleWindow->GetWindow(&fMenuBandWindow);
fMenuBar.Attach(menuBar.Detach()); // transfer the ref count
+ /* FIXME
hResult = CreateBrandBand(&logoBar);
if (FAILED(hResult))
return hResult;
AddDockItem(logoBar, ITBBID_BRANDBAND,
CDockSite::ITF_NOGRIPPER | CDockSite::ITF_NOTITLE | CDockSite::ITF_FIXEDSIZE);
fLogoBar.Attach(logoBar.Detach()); // transfer the ref count
+ */
hResult = CreateToolsBar(&toolsBar);
if (FAILED(hResult))
}
return fBandProxy->QueryInterface(riid, ppvObject);
}
- hResult = fSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
- if (FAILED(hResult))
- return hResult;
- return serviceProvider->QueryService(guidService, riid, ppvObject);
+ return IUnknown_QueryService(fSite, guidService, riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE CInternetToolbar::OnWinEvent(
CComPtr<IWinEventHandler> menuWinEventHandler;
HRESULT hResult;
- if (fMenuBar.p != NULL)
+ if (fMenuBar)
{
hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
- return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
+ if (menuWinEventHandler->IsWindowOwner(hWnd))
+ {
+ return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
+ }
}
- return E_FAIL;
+
+ return S_FALSE;
}
HRESULT STDMETHODCALLTYPE CInternetToolbar::IsWindowOwner(HWND hWnd)
return E_POINTER;
if (dwBandID == ITBBID_MENUBAND && fMenuBar.p != NULL)
return fMenuBar->QueryInterface(IID_IDeskBand, reinterpret_cast<void **>(ppstb));
- if (dwBandID == ITBBID_BRANDBAND && fLogoBar.p != NULL)
- return fLogoBar->QueryInterface(IID_IDeskBand, reinterpret_cast<void **>(ppstb));
+ //if (dwBandID == ITBBID_BRANDBAND && fLogoBar.p != NULL)
+ // return fLogoBar->QueryInterface(IID_IDeskBand, reinterpret_cast<void **>(ppstb));
*ppstb = NULL;
return E_FAIL;
}
return 1;
}
-LRESULT CInternetToolbar::OnNavigateCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
-{
- CComPtr<IWinEventHandler> winEventHandler;
- LRESULT theResult;
- HRESULT hResult;
-
- hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&winEventHandler));
- hResult = winEventHandler->OnWinEvent(m_hWnd, uMsg, wParam, lParam, &theResult);
- if (SUCCEEDED(hResult))
- return theResult;
- bHandled = FALSE;
- return 0;
-}
-
LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
HMENU contextMenuBar;
return 0;
}
+LRESULT CInternetToolbar::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+ LRESULT theResult;
+ HRESULT hResult;
+ HWND target = (HWND) lParam;
+
+ if (fMenuBar)
+ {
+ CComPtr<IWinEventHandler> menuWinEventHandler;
+ hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+ if (SUCCEEDED(hResult))
+ {
+ if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
+ {
+ hResult = menuWinEventHandler->OnWinEvent(target, uMsg, wParam, lParam, &theResult);
+ return FAILED(hResult) ? 0 : theResult;
+ }
+ }
+ }
+
+ if (fNavigationBar)
+ {
+ CComPtr<IWinEventHandler> menuWinEventHandler;
+ hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+ if (SUCCEEDED(hResult))
+ {
+ if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
+ {
+ hResult = menuWinEventHandler->OnWinEvent(target, uMsg, wParam, lParam, &theResult);
+ return FAILED(hResult) ? 0 : theResult;
+ }
+ }
+ }
+
+ return 0;
+}
LRESULT CInternetToolbar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
- NMHDR *notifyHeader;
- CComPtr<IWinEventHandler> menuWinEventHandler;
- LRESULT theResult;
- HRESULT hResult;
+ NMHDR *notifyHeader;
+ LRESULT theResult;
+ HRESULT hResult;
+
+ notifyHeader = (NMHDR *) lParam;
- notifyHeader = (NMHDR *)lParam;
- if (fMenuBar.p != NULL && notifyHeader->hwndFrom == fMenuBandWindow)
+ if (fMenuBar)
{
+ CComPtr<IWinEventHandler> menuWinEventHandler;
hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
- hResult = menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, &theResult);
- return theResult;
+ if (SUCCEEDED(hResult))
+ {
+ if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
+ {
+ hResult = menuWinEventHandler->OnWinEvent(notifyHeader->hwndFrom, uMsg, wParam, lParam, &theResult);
+ return FAILED(hResult) ? 0 : theResult;
+ }
+ }
}
- if (fNavigationBar.p != NULL && notifyHeader->hwndFrom == fNavigationWindow)
+
+ if (fNavigationBar)
{
- hResult = fNavigationBar->QueryInterface(
- IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
- hResult = menuWinEventHandler->OnWinEvent(m_hWnd, uMsg, wParam, lParam, &theResult);
- return theResult;
+ CComPtr<IWinEventHandler> menuWinEventHandler;
+ hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+ if (SUCCEEDED(hResult))
+ {
+ if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
+ {
+ hResult = menuWinEventHandler->OnWinEvent(notifyHeader->hwndFrom, uMsg, wParam, lParam, &theResult);
+ return FAILED(hResult) ? 0 : theResult;
+ }
+ }
}
+
return 0;
}