#include "precomp.h"
+/* FIXME, I can't include windowsx because it conflicts with some #defines */
+#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
+#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
+
+#define USE_CUSTOM_MENUBAND 0
+
// navigation controls and menubar just send a message to parent window
/*
TODO:
HRESULT CDockSite::Initialize(IUnknown *containedBand, CInternetToolbar *browser, HWND hwnd, int bandID, int flags)
{
- CComPtr<IObjectWithSite> site;
+ CComPtr<IObjectWithSite> child;
CComPtr<IOleWindow> oleWindow;
CComPtr<IDeskBand> deskBand;
TCHAR textBuffer[40];
REBARBANDINFOW bandInfo;
HRESULT hResult;
- hResult = containedBand->QueryInterface(IID_IObjectWithSite, reinterpret_cast<void **>(&site));
+ hResult = containedBand->QueryInterface(IID_PPV_ARG(IObjectWithSite, &child));
if (FAILED(hResult))
return hResult;
- hResult = containedBand->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&oleWindow));
+ hResult = containedBand->QueryInterface(IID_PPV_ARG(IOleWindow, &oleWindow));
if (FAILED(hResult))
return hResult;
- hResult = containedBand->QueryInterface(IID_IDeskBand, reinterpret_cast<void **>(&deskBand));
+ hResult = containedBand->QueryInterface(IID_PPV_ARG(IDeskBand, &deskBand));
if (FAILED(hResult))
return hResult;
fContainedBand = containedBand;
fRebarWindow = hwnd;
fBandID = bandID;
fFlags = flags;
- hResult = site->SetSite(static_cast<IOleWindow *>(this));
+ hResult = child->SetSite(static_cast<IOleWindow *>(this));
if (FAILED(hResult))
return hResult;
hResult = oleWindow->GetWindow(&fChildWindow);
CComPtr<IDeskBand> deskBand;
HRESULT hResult;
- hResult = fContainedBand->QueryInterface(IID_IDeskBand, reinterpret_cast<void **>(&deskBand));
+ hResult = fContainedBand->QueryInterface(IID_PPV_ARG(IDeskBand, &deskBand));
if (FAILED(hResult))
return hResult;
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()
if (fFavoritesMenu.p == NULL)
{
// create favorites menu
- hResult = psmd->punk->QueryInterface(IID_IShellMenu, reinterpret_cast<void **>(&parentMenu));
+ hResult = psmd->punk->QueryInterface(IID_PPV_ARG(IShellMenu, &parentMenu));
if (FAILED(hResult))
return hResult;
hResult = parentMenu->GetMenu(&parentHMenu, &ownerWindow, NULL);
favoritesHMenu = GetSubMenu(parentHMenu, 3);
if (favoritesHMenu == NULL)
return E_FAIL;
-#if 1
+#if USE_CUSTOM_MENUBAND
HMODULE hrs = LoadLibrary(L"rshell.dll");
PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
else
{
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
- IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
+ IID_PPV_ARG(IShellMenu, &newMenu));
}
#else
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
- IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
+ IID_PPV_ARG(IShellMenu, &newMenu));
#endif
if (FAILED(hResult))
return hResult;
newSite->Initialize(newItem, this, fMainReBar, bandID, flags);
}
-HRESULT CInternetToolbar::ReserveBorderSpace()
+HRESULT CInternetToolbar::ReserveBorderSpace(LONG maxHeight)
{
CComPtr<IDockingWindowSite> dockingWindowSite;
RECT availableBorderSpace;
- RECT neededBorderSpace;
- HRESULT hResult;
- hResult = fSite->QueryInterface(IID_IDockingWindowSite, reinterpret_cast<void **>(&dockingWindowSite));
+ HRESULT hResult = fSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &dockingWindowSite));
if (FAILED(hResult))
return hResult;
hResult = dockingWindowSite->GetBorderDW(static_cast<IDockingWindow *>(this), &availableBorderSpace);
if (FAILED(hResult))
return hResult;
- SendMessage(fMainReBar, RB_SIZETORECT, RBSTR_CHANGERECT, reinterpret_cast<LPARAM>(&availableBorderSpace));
- neededBorderSpace.left = 0;
- neededBorderSpace.top = availableBorderSpace.bottom - availableBorderSpace.top;
- if (!fLocked)
- neededBorderSpace.top += 3;
- neededBorderSpace.right = 0;
- neededBorderSpace.bottom = 0;
- hResult = dockingWindowSite->SetBorderSpaceDW(static_cast<IDockingWindow *>(this), &neededBorderSpace);
- if (FAILED(hResult))
- return hResult;
- return S_OK;
+
+ if (availableBorderSpace.top > maxHeight)
+ {
+ availableBorderSpace.top = maxHeight;
+ }
+
+ return ResizeBorderDW(&availableBorderSpace, fSite, FALSE);
}
HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
HWND ownerWindow;
HRESULT hResult;
-#if 1
+#if USE_CUSTOM_MENUBAND
HMODULE hrs = LoadLibraryW(L"rshell.dll");
if (!hrs)
if (FAILED(hResult))
{
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
- IID_IShellMenu, reinterpret_cast<void **>(menuBar));
+ IID_PPV_ARG(IShellMenu, menuBar));
}
#else
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
- IID_IShellMenu, reinterpret_cast<void **>(menuBar));
+ IID_PPV_ARG(IShellMenu, menuBar));
#endif
if (FAILED(hResult))
return hResult;
- hResult = fMenuCallback.QueryInterface(IID_IShellMenuCallback, reinterpret_cast<void **>(&callback));
+ hResult = fMenuCallback.QueryInterface(IID_PPV_ARG(IShellMenuCallback, &callback));
if (FAILED(hResult))
return hResult;
hResult = (*menuBar)->Initialize(callback, -1, ANCESTORDEFAULT, SMINIT_HORIZONTAL | SMINIT_TOPLEVEL);
if (FAILED(hResult))
return hResult;
- hResult = fSite->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&oleWindow));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IOleWindow, &oleWindow));
if (FAILED(hResult))
return hResult;
hResult = oleWindow->GetWindow(&ownerWindow);
if (FAILED(hResult))
return hResult;
- hResult = fSite->QueryInterface(IID_IOleCommandTarget, reinterpret_cast<void **>(&siteCommandTarget));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &siteCommandTarget));
if (FAILED(hResult))
return hResult;
hResult = siteCommandTarget->Exec(&CGID_Explorer, 0x35, 0, NULL, &menuOut);
hResult = (*menuBar)->SetMenu((HMENU)V_INTREF(&menuOut), ownerWindow, SMSET_DONTOWN);
if (FAILED(hResult))
return hResult;
- hResult = (*menuBar)->QueryInterface(IID_IOleCommandTarget, reinterpret_cast<void **>(&commandTarget));
+ hResult = (*menuBar)->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &commandTarget));
if (FAILED(hResult))
return hResult;
hResult = commandTarget->Exec(&CGID_MenuBand, 3, 1, NULL, NULL);
HRESULT hResult;
#if 1
- hResult = ::CreateBrandBand(IID_IUnknown, reinterpret_cast<void **>(logoBar));
+ hResult = ::CreateBrandBand(IID_PPV_ARG(IUnknown, logoBar));
#else
- hResult = CoCreateInstance(CLSID_BrandBand, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown,
- reinterpret_cast<void **>(logoBar));
+ hResult = CoCreateInstance(CLSID_BrandBand, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IUnknown, logoBar));
#endif
if (FAILED(hResult))
return hResult;
{
HRESULT hResult;
- hResult = ::CreateToolsBar(IID_IUnknown, reinterpret_cast<void **>(toolsBar));
+ hResult = ::CreateToolsBar(IID_PPV_ARG(IUnknown, toolsBar));
if (FAILED(hResult))
return hResult;
return S_OK;
HRESULT hResult;
#if 1
- hResult = ::CreateAddressBand(IID_IUnknown, reinterpret_cast<void **>(toolsBar));
+ hResult = ::CreateAddressBand(IID_PPV_ARG(IUnknown, toolsBar));
#else
- hResult = CoCreateInstance(CLSID_SH_AddressBand, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown,
- reinterpret_cast<void **>(toolsBar));
+ hResult = CoCreateInstance(CLSID_SH_AddressBand, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IUnknown, toolsBar));
#endif
if (FAILED(hResult))
return hResult;
- hResult = (*toolsBar)->QueryInterface(IID_IAddressBand, reinterpret_cast<void **>(&addressBand));
+ hResult = (*toolsBar)->QueryInterface(IID_PPV_ARG(IAddressBand, &addressBand));
return S_OK;
}
}
}
hResult = ReserveBorderSpace();
+
+ // TODO: refresh view menu?
}
return S_OK;
}
break;
case 1:
// forward
- hResult = SetState(&CLSID_CommonButtons, gForwardCommandID, newValue ? TBSTATE_ENABLED : 0);
+ hResult = SetState(&CLSID_CommonButtons, IDM_GOTO_FORWARD, newValue ? TBSTATE_ENABLED : 0);
break;
case 2:
// back
- hResult = SetState(&CLSID_CommonButtons, gBackCommandID, newValue ? TBSTATE_ENABLED : 0);
+ hResult = SetState(&CLSID_CommonButtons, IDM_GOTO_BACK, newValue ? TBSTATE_ENABLED : 0);
break;
}
return hResult;
CComPtr<IServiceProvider> serviceProvider;
HRESULT hResult;
- hResult = fSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
if (FAILED(hResult))
return hResult;
- hResult = serviceProvider->QueryService(SID_IBandProxy, IID_IBandProxy, reinterpret_cast<void **>(&fBandProxy));
+ hResult = serviceProvider->QueryService(SID_IBandProxy, IID_PPV_ARG(IBandProxy, &fBandProxy));
if (FAILED(hResult))
{
- hResult = CreateBandProxy(IID_IBandProxy, reinterpret_cast<void **>(&fBandProxy));
+ hResult = CreateBandProxy(IID_PPV_ARG(IBandProxy, &fBandProxy));
if (FAILED(hResult))
return hResult;
hResult = fBandProxy->SetSite(fSite);
// show the bar here
hResult = ReserveBorderSpace();
- hResult = fMenuBar->QueryInterface(IID_IDockingWindow, reinterpret_cast<void **>(&dockingWindow));
+ hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
hResult = dockingWindow->ShowDW(fShow);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CInternetToolbar::ResizeBorderDW(LPCRECT prcBorder,
IUnknown *punkToolbarSite, BOOL fReserved)
{
- return E_NOTIMPL;
+ RECT neededBorderSpace;
+ RECT availableBorderSpace = *prcBorder;
+
+ SendMessage(fMainReBar, RB_SIZETORECT, RBSTR_CHANGERECT, reinterpret_cast<LPARAM>(&availableBorderSpace));
+
+ // RBSTR_CHANGERECT does not seem to set the proper size in the rect.
+ // Let's make sure we fetch the actual size properly.
+ GetWindowRect(fMainReBar, &availableBorderSpace);
+ neededBorderSpace.left = 0;
+ neededBorderSpace.top = availableBorderSpace.bottom - availableBorderSpace.top;
+ if (!fLocked)
+ neededBorderSpace.top += 3;
+ neededBorderSpace.right = 0;
+ neededBorderSpace.bottom = 0;
+
+ CComPtr<IDockingWindowSite> dockingWindowSite;
+
+ HRESULT hResult = fSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &dockingWindowSite));
+ if (FAILED(hResult))
+ return hResult;
+
+ hResult = dockingWindowSite->RequestBorderSpaceDW(static_cast<IDockingWindow *>(this), &neededBorderSpace);
+ if (FAILED(hResult))
+ return hResult;
+
+ hResult = dockingWindowSite->SetBorderSpaceDW(static_cast<IDockingWindow *>(this), &neededBorderSpace);
+ if (FAILED(hResult))
+ return hResult;
+
+ return S_OK;
}
HRESULT STDMETHODCALLTYPE CInternetToolbar::GetClassID(CLSID *pClassID)
CComPtr<IOleWindow> navigationOleWindow;
HRESULT hResult;
+ /* Create and attach the menubar to the rebar */
hResult = CreateMenuBar(&menuBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(menuBar, ITBBID_MENUBAND,
- CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
+ AddDockItem(menuBar, ITBBID_MENUBAND, CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
- hResult = menuBar->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&menuOleWindow));
+ hResult = menuBar->QueryInterface(IID_PPV_ARG(IOleWindow, &menuOleWindow));
hResult = menuOleWindow->GetWindow(&fMenuBandWindow);
fMenuBar.Attach(menuBar.Detach()); // transfer the ref count
+ // FIXME: The ros Rebar does not properly support fixed-size items such as the brandband,
+ // and it will put them in their own row, sized to take up the whole row.
+#if 0
+ /* Create and attach the brand/logo to the rebar */
hResult = CreateBrandBand(&logoBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(logoBar, ITBBID_BRANDBAND,
- CDockSite::ITF_NOGRIPPER | CDockSite::ITF_NOTITLE | CDockSite::ITF_FIXEDSIZE);
+ AddDockItem(logoBar, ITBBID_BRANDBAND, CDockSite::ITF_NOGRIPPER | CDockSite::ITF_NOTITLE | CDockSite::ITF_FIXEDSIZE);
fLogoBar.Attach(logoBar.Detach()); // transfer the ref count
+#endif
+ /* Create and attach the standard toolbar to the rebar */
hResult = CreateToolsBar(&toolsBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(toolsBar, ITBBID_TOOLSBAND, CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS);
+ AddDockItem(toolsBar, ITBBID_TOOLSBAND, CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
fControlsBar.Attach(toolsBar.Detach()); // transfer the ref count
- hResult = fControlsBar->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&toolbarOleWindow));
+ hResult = fControlsBar->QueryInterface(IID_PPV_ARG(IOleWindow, &toolbarOleWindow));
if (FAILED(hResult))
return hResult;
hResult = toolbarOleWindow->GetWindow(&fToolbarWindow);
if (FAILED(hResult))
return hResult;
+ /* Create and attach the address/navigation toolbar to the rebar */
hResult = CreateAddressBand(&navigationBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(navigationBar, ITBBID_ADDRESSBAND, CDockSite::ITF_NEWBANDALWAYS);
- hResult = navigationBar->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&navigationOleWindow));
+ AddDockItem(navigationBar, ITBBID_ADDRESSBAND, CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
+ hResult = navigationBar->QueryInterface(IID_PPV_ARG(IOleWindow, &navigationOleWindow));
hResult = navigationOleWindow->GetWindow(&fNavigationWindow);
fNavigationBar.Attach(navigationBar.Detach());
HRESULT hResult;
fCommandTarget.Release();
- hResult = theTarget->QueryInterface(IID_IOleCommandTarget, reinterpret_cast<void **>(&fCommandTarget));
+ hResult = theTarget->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &fCommandTarget));
if (FAILED(hResult))
return hResult;
fCommandCategory = *category;
HWND ownerWindow;
HWND dockContainer;
HRESULT hResult;
- DWORD style;
if (pUnkSite == NULL)
{
else
{
// get window handle of owner
- hResult = pUnkSite->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&oleWindow));
+ hResult = pUnkSite->QueryInterface(IID_PPV_ARG(IOleWindow, &oleWindow));
if (FAILED(hResult))
return hResult;
hResult = oleWindow->GetWindow(&ownerWindow);
SubclassWindow(dockContainer);
// create rebar in dock container
- style = WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT |
- RBS_BANDBORDERS | RBS_REGISTERDROP | RBS_AUTOSIZE | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_TOP;
- fMainReBar = CreateWindow(REBARCLASSNAMEW, NULL, style,
+ DWORD style = WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
+ RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_REGISTERDROP | RBS_AUTOSIZE | RBS_DBLCLKTOGGLE |
+ CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_TOP;
+ DWORD exStyle = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_TOOLWINDOW;
+ fMainReBar = CreateWindowEx(exStyle, REBARCLASSNAMEW, NULL, style,
0, 0, 700, 60, dockContainer, NULL, _AtlBaseModule.GetModuleInstance(), NULL);
if (fMainReBar == NULL)
return E_FAIL;
// take advice to watch events
- hResult = pUnkSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
+ hResult = pUnkSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
hResult = serviceProvider->QueryService(
- SID_SShellBrowser, IID_IBrowserService, reinterpret_cast<void **>(&browserService));
+ SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &browserService));
hResult = AtlAdvise(browserService, static_cast<IDispatch *>(this), DIID_DWebBrowserEvents, &fAdviseCookie);
}
return S_OK;
}
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(
if (fMenuBar)
{
- hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
- if (menuWinEventHandler->IsWindowOwner(hWnd))
+ hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
+ if (menuWinEventHandler->IsWindowOwner(hWnd) == S_OK)
{
return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
}
if (ppstb == NULL)
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));
+ return fMenuBar->QueryInterface(IID_PPV_ARG(IDeskBand, ppstb));
+ //if (dwBandID == ITBBID_BRANDBAND && fLogoBar.p != NULL)
+ // return fLogoBar->QueryInterface(IID_PPV_ARG(IDeskBand, ppstb));
*ppstb = NULL;
return E_FAIL;
}
CComPtr<IWebBrowser> webBrowser;
HRESULT hResult;
- hResult = fSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
if (FAILED(hResult))
return 0;
hResult = serviceProvider->QueryService(SID_SShellBrowser,
- IID_IWebBrowser, reinterpret_cast<void **>(&webBrowser));
+ IID_PPV_ARG(IWebBrowser, &webBrowser));
if (FAILED(hResult))
return 0;
hResult = webBrowser->GoBack();
CComPtr<IWebBrowser> webBrowser;
HRESULT hResult;
- hResult = fSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
if (FAILED(hResult))
return 0;
hResult = serviceProvider->QueryService(
- SID_SShellBrowser, IID_IWebBrowser, reinterpret_cast<void **>(&webBrowser));
+ SID_SShellBrowser, IID_PPV_ARG(IWebBrowser, &webBrowser));
if (FAILED(hResult))
return 0;
hResult = webBrowser->GoForward();
CComPtr<IOleCommandTarget> oleCommandTarget;
HRESULT hResult;
- hResult = fSite->QueryInterface(IID_IOleCommandTarget, reinterpret_cast<void **>(&oleCommandTarget));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
if (FAILED(hResult))
return hResult;
hResult = oleCommandTarget->Exec(&CGID_ShellBrowser, IDM_GOTO_UPONELEVEL, 0, NULL, NULL);
commandInfo.nShow = SW_SHOWNORMAL;
hResult = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
- IID_IContextMenu, reinterpret_cast<void **>(&contextMenu));
+ IID_PPV_ARG(IContextMenu, &contextMenu));
if (FAILED(hResult))
return 0;
- hResult = contextMenu->QueryInterface(IID_IObjectWithSite, reinterpret_cast<void **>(&objectWithSite));
+ hResult = contextMenu->QueryInterface(IID_PPV_ARG(IObjectWithSite, &objectWithSite));
if (FAILED(hResult))
return 0;
hResult = objectWithSite->SetSite(fSite);
CComPtr<IOleCommandTarget> oleCommandTarget;
HRESULT hResult;
- hResult = fSite->QueryInterface(IID_IOleCommandTarget, reinterpret_cast<void **>(&oleCommandTarget));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
if (FAILED(hResult))
return hResult;
hResult = oleCommandTarget->Exec(&CGID_Explorer, 0x23, 0, NULL, NULL);
::MapWindowPoints(fToolbarWindow, NULL, reinterpret_cast<POINT *>(&bounds), 2);
switch (notifyInfo->iItem)
{
- case gBackCommandID:
+ case IDM_GOTO_BACK:
newMenu = CreatePopupMenu();
- hResult = fSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
hResult = serviceProvider->QueryService(
- SID_SShellBrowser, IID_IBrowserService, reinterpret_cast<void **>(&browserService));
+ SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &browserService));
hResult = browserService->GetTravelLog(&travelLog);
hResult = travelLog->InsertMenuEntries(browserService, newMenu, 0, 1, 9, TLMENUF_BACK);
- hResult = browserService->QueryInterface(IID_IOleCommandTarget, reinterpret_cast<void **>(&commandTarget));
+ hResult = browserService->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &commandTarget));
commandInfo.cmdID = 0x1d;
hResult = commandTarget->QueryStatus(&CGID_Explorer, 1, &commandInfo, NULL);
if ((commandInfo.cmdf & (OLECMDF_ENABLED | OLECMDF_LATCHED)) == OLECMDF_ENABLED &&
hResult = travelLog->Travel(browserService, -selectedItem);
DestroyMenu(newMenu);
break;
- case gForwardCommandID:
+ case IDM_GOTO_FORWARD:
newMenu = CreatePopupMenu();
- hResult = fSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&serviceProvider));
- hResult = serviceProvider->QueryService(SID_SShellBrowser, IID_IBrowserService,
- reinterpret_cast<void **>(&browserService));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
+ hResult = serviceProvider->QueryService(SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &browserService));
hResult = browserService->GetTravelLog(&travelLog);
hResult = travelLog->InsertMenuEntries(browserService, newMenu, 0, 1, 9, TLMENUF_FORE);
- hResult = browserService->QueryInterface(IID_IOleCommandTarget, reinterpret_cast<void **>(&commandTarget));
+ hResult = browserService->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &commandTarget));
commandInfo.cmdID = 0x1d;
hResult = commandTarget->QueryStatus(&CGID_Explorer, 1, &commandInfo, NULL);
if ((commandInfo.cmdf & (OLECMDF_ENABLED | OLECMDF_LATCHED)) == OLECMDF_ENABLED &&
default:
break;
}
+
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STATE;
+ mii.fState = fLocked ? MFS_CHECKED : MFS_UNCHECKED;
+ command = SetMenuItemInfo(contextMenu, IDM_TOOLBARS_LOCKTOOLBARS, FALSE, &mii);
+
// TODO: use GetSystemMetrics(SM_MENUDROPALIGNMENT) to determine menu alignment
command = TrackPopupMenu(contextMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
clickLocation.x, clickLocation.y, 0, m_hWnd, NULL);
if (nID != 0)
{
- if (nID == (UINT)gBackCommandID || nID == (UINT)gForwardCommandID)
+ if (nID == (UINT)IDM_GOTO_BACK || nID == (UINT)IDM_GOTO_FORWARD)
{
// TODO: Should this call QueryService?
- hResult = fSite->QueryInterface(IID_IBrowserService, reinterpret_cast<void **>(&browserService));
+ hResult = fSite->QueryInterface(IID_PPV_ARG(IBrowserService, &browserService));
hResult = browserService->GetTravelLog(&travelLog);
hResult = travelLog->GetToolTipText(browserService,
- (nID == (UINT)gBackCommandID) ? TLOG_BACK : TLOG_FORE,
+ (nID == (UINT)IDM_GOTO_BACK) ? TLOG_BACK : TLOG_FORE,
0, tempString, 299);
if (FAILED(hResult))
{
if (fMenuBar)
{
CComPtr<IWinEventHandler> menuWinEventHandler;
- hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+ hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
if (SUCCEEDED(hResult))
{
if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
if (fNavigationBar)
{
CComPtr<IWinEventHandler> menuWinEventHandler;
- hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+ hResult = fNavigationBar->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
if (SUCCEEDED(hResult))
{
if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
if (fMenuBar)
{
CComPtr<IWinEventHandler> menuWinEventHandler;
- hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+ hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
if (SUCCEEDED(hResult))
{
if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
if (fNavigationBar)
{
CComPtr<IWinEventHandler> menuWinEventHandler;
- hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+ hResult = fNavigationBar->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
if (SUCCEEDED(hResult))
{
if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
return 0;
}
+LRESULT CInternetToolbar::OnLDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+ bHandled = FALSE;
+ if (fLocked)
+ return 0;
+
+ if (wParam & MK_CONTROL)
+ return 0;
+
+ fSizing = TRUE;
+
+ DWORD msgp = GetMessagePos();
+
+ fStartPosition.x = GET_X_LPARAM(msgp);
+ fStartPosition.y = GET_Y_LPARAM(msgp);
+
+ RECT rc;
+ GetWindowRect(m_hWnd, &rc);
+
+ fStartHeight = rc.bottom - rc.top;
+
+ SetCapture();
+
+ bHandled = TRUE;
+ return 0;
+}
+
+LRESULT CInternetToolbar::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+ bHandled = FALSE;
+ if (!fSizing)
+ return 0;
+
+ DWORD msgp = GetMessagePos();
+
+ POINT pt;
+ pt.x = GET_X_LPARAM(msgp);
+ pt.y = GET_Y_LPARAM(msgp);
+
+ ReserveBorderSpace(fStartHeight - fStartPosition.y + pt.y);
+
+ bHandled = TRUE;
+ return 0;
+}
+
+LRESULT CInternetToolbar::OnLUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+ bHandled = FALSE;
+ if (!fSizing)
+ return 0;
+
+ OnMouseMove(uMsg, wParam, lParam, bHandled);
+
+ fSizing = FALSE;
+
+ ReleaseCapture();
+
+ return 0;
+}
+
HRESULT CreateInternetToolbar(REFIID riid, void **ppv)
{
CComObject<CInternetToolbar> *theToolbar;