From 502f155b91f94f2713e75eecfb7bbd70bf429113 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Thu, 11 Dec 2014 17:42:56 +0000 Subject: [PATCH] [EXPLORER] - Simplify some code by using the IUnknown_ exports of shlwapi and using CComPtr. svn path=/trunk/; revision=65605 --- reactos/base/shell/explorer/taskband.cpp | 54 +++++++----------------- reactos/base/shell/explorer/tbsite.cpp | 20 ++------- 2 files changed, 18 insertions(+), 56 deletions(-) diff --git a/reactos/base/shell/explorer/taskband.cpp b/reactos/base/shell/explorer/taskband.cpp index b5100e74b5a..d925c58049c 100644 --- a/reactos/base/shell/explorer/taskband.cpp +++ b/reactos/base/shell/explorer/taskband.cpp @@ -272,55 +272,31 @@ public: virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite) { - HRESULT hRet = E_FAIL; + HRESULT hRet; + HWND hwndSite; TRACE("ITaskBand::SetSite(0x%p)\n", pUnkSite); - /* Release the current site */ - if (m_Site != NULL) + hRet = IUnknown_GetWindow(pUnkSite, &hwndSite); + if (FAILED(hRet)) { - m_Site->Release(); + TRACE("Querying site window failed: 0x%x\n", hRet); + return hRet; } - m_Site = NULL; - m_hWnd = NULL; + TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hwndSite); - if (pUnkSite != NULL) + HWND hwndTaskSwitch = CreateTaskSwitchWnd(hwndSite, m_Tray); + if (!hwndTaskSwitch) { - CComPtr OleWindow; - - /* Check if the site supports IOleWindow */ - hRet = pUnkSite->QueryInterface(IID_PPV_ARG(IOleWindow, &OleWindow)); - if (SUCCEEDED(hRet)) - { - HWND hWndParent = NULL; - - hRet = OleWindow->GetWindow(&hWndParent); - if (SUCCEEDED(hRet)) - { - /* Attempt to create the task switch window */ - - TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hWndParent); - m_hWnd = CreateTaskSwitchWnd(hWndParent, m_Tray); - if (m_hWnd != NULL) - { - m_Site = pUnkSite; - hRet = S_OK; - } - else - { - TRACE("CreateTaskSwitchWnd() failed!\n"); - hRet = E_FAIL; - } - } - } - else - { - TRACE("Querying IOleWindow failed: 0x%x\n", hRet); - } + ERR("CreateTaskSwitchWnd failed"); + return E_FAIL; } - return hRet; + m_Site = pUnkSite; + m_hWnd = hwndTaskSwitch; + + return S_OK; } virtual HRESULT STDMETHODCALLTYPE GetSite( diff --git a/reactos/base/shell/explorer/tbsite.cpp b/reactos/base/shell/explorer/tbsite.cpp index 41574db90dd..93e38a7085a 100644 --- a/reactos/base/shell/explorer/tbsite.cpp +++ b/reactos/base/shell/explorer/tbsite.cpp @@ -350,23 +350,9 @@ public: virtual HRESULT STDMETHODCALLTYPE AddBand(IN IUnknown *punk) { - IOleCommandTarget *pOct; - HRESULT hRet; - - hRet = punk->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &pOct)); - if (SUCCEEDED(hRet)) - { - /* Send the DBID_DELAYINIT command to initialize the band to be added */ - /* FIXME: Should be delayed */ - pOct->Exec( - &IID_IDeskBand, - DBID_DELAYINIT, - 0, - NULL, - NULL); - - pOct->Release(); - } + /* Send the DBID_DELAYINIT command to initialize the band to be added */ + /* FIXME: Should be delayed */ + IUnknown_Exec(punk, IID_IDeskBand, DBID_DELAYINIT, 0, NULL, NULL); return m_BandSite->AddBand(punk); }