[BROWSEUI]
[reactos.git] / dll / win32 / browseui / internettoolbar.cpp
index ec48dd9..b1c33cc 100644 (file)
@@ -161,13 +161,13 @@ HRESULT CDockSite::Initialize(IUnknown *containedBand, CInternetToolbar *browser
     REBARBANDINFOW                          bandInfo;
     HRESULT                                 hResult;
 
-    hResult = containedBand->QueryInterface(IID_IObjectWithSite, reinterpret_cast<void **>(&site));
+    hResult = containedBand->QueryInterface(IID_PPV_ARG(IObjectWithSite, &site));
     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;
@@ -199,7 +199,7 @@ HRESULT CDockSite::GetRBBandInfo(REBARBANDINFOW &bandInfo)
     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;
 
@@ -362,7 +362,7 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
     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);
@@ -382,11 +382,11 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
         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;
@@ -521,13 +521,16 @@ HRESULT CInternetToolbar::ReserveBorderSpace()
     RECT                                    neededBorderSpace;
     HRESULT                                 hResult;
 
-    hResult = fSite->QueryInterface(IID_IDockingWindowSite, reinterpret_cast<void **>(&dockingWindowSite));
+    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));
+    // 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)
@@ -573,27 +576,27 @@ HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
     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);
@@ -604,7 +607,7 @@ HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
     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);
@@ -619,10 +622,9 @@ HRESULT CInternetToolbar::CreateBrandBand(IUnknown **logoBar)
     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;
@@ -633,7 +635,7 @@ HRESULT CInternetToolbar::CreateToolsBar(IUnknown **toolsBar)
 {
     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;
@@ -645,14 +647,13 @@ HRESULT CInternetToolbar::CreateAddressBand(IUnknown **toolsBar)
     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;
 }
 
@@ -719,13 +720,13 @@ HRESULT CInternetToolbar::CreateAndInitBandProxy()
     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);
@@ -770,7 +771,7 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::ShowDW(BOOL fShow)
 
     // 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;
 }
@@ -817,7 +818,7 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::GetSizeMax(ULARGE_INTEGER *pcbSize)
 HRESULT STDMETHODCALLTYPE CInternetToolbar::InitNew()
 {
     CComPtr<IShellMenu>                     menuBar;
-    //CComPtr<IUnknown>                       logoBar;
+    CComPtr<IUnknown>                       logoBar;
     CComPtr<IUnknown>                       toolsBar;
     CComPtr<IUnknown>                       navigationBar;
     CComPtr<IOleWindow>                     menuOleWindow;
@@ -825,42 +826,44 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::InitNew()
     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);
 
-    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
+    /* 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);
     fLogoBar.Attach(logoBar.Detach());                  // transfer the ref count
-    */
 
+    /* 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());
 
@@ -1000,7 +1003,7 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::SetCommandTarget(IUnknown *theTarget
     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;
@@ -1095,7 +1098,6 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::SetSite(IUnknown *pUnkSite)
     HWND                                    ownerWindow;
     HWND                                    dockContainer;
     HRESULT                                 hResult;
-    DWORD                                   style;
 
     if (pUnkSite == NULL)
     {
@@ -1107,7 +1109,7 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::SetSite(IUnknown *pUnkSite)
     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);
@@ -1125,17 +1127,19 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::SetSite(IUnknown *pUnkSite)
         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;
@@ -1179,7 +1183,7 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::OnWinEvent(
 
     if (fMenuBar)
     {
-        hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+        hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
         if (menuWinEventHandler->IsWindowOwner(hWnd))
         {
             return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
@@ -1210,9 +1214,9 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::QueryBand(DWORD dwBandID,
     if (ppstb == NULL)
         return E_POINTER;
     if (dwBandID == ITBBID_MENUBAND && fMenuBar.p != NULL)
-        return fMenuBar->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_IDeskBand, reinterpret_cast<void **>(ppstb));
+    //    return fLogoBar->QueryInterface(IID_PPV_ARG(IDeskBand, ppstb));
     *ppstb = NULL;
     return E_FAIL;
 }
@@ -1248,11 +1252,11 @@ LRESULT CInternetToolbar::OnTravelBack(WORD wNotifyCode, WORD wID, HWND hWndCtl,
     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();
@@ -1265,11 +1269,11 @@ LRESULT CInternetToolbar::OnTravelForward(WORD wNotifyCode, WORD wID, HWND hWndC
     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();
@@ -1281,7 +1285,7 @@ LRESULT CInternetToolbar::OnUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
     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);
@@ -1305,10 +1309,10 @@ LRESULT CInternetToolbar::OnSearch(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
     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);
@@ -1324,7 +1328,7 @@ LRESULT CInternetToolbar::OnFolders(WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
     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);
@@ -1370,12 +1374,12 @@ LRESULT CInternetToolbar::OnMenuDropDown(UINT idControl, NMHDR *pNMHDR, BOOL &bH
     {
         case gBackCommandID:
             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 &&
@@ -1400,12 +1404,11 @@ LRESULT CInternetToolbar::OnMenuDropDown(UINT idControl, NMHDR *pNMHDR, BOOL &bH
             break;
         case gForwardCommandID:
             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 &&
@@ -1562,7 +1565,7 @@ LRESULT CInternetToolbar::OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandle
         if (nID == (UINT)gBackCommandID || nID == (UINT)gForwardCommandID)
         {
             // 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,
@@ -1592,7 +1595,7 @@ LRESULT CInternetToolbar::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOO
     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)
@@ -1606,7 +1609,7 @@ LRESULT CInternetToolbar::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOO
     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)
@@ -1630,7 +1633,7 @@ LRESULT CInternetToolbar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
     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)
@@ -1644,7 +1647,7 @@ LRESULT CInternetToolbar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
     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)