Author: gadamopoulos
Date: Thu Dec 11 17:42:56 2014
New Revision: 65605

URL: http://svn.reactos.org/svn/reactos?rev=65605&view=rev
Log:
[EXPLORER]
- Simplify some code by using the IUnknown_ exports of shlwapi and using 
CComPtr.

Modified:
    trunk/reactos/base/shell/explorer/taskband.cpp
    trunk/reactos/base/shell/explorer/tbsite.cpp

Modified: trunk/reactos/base/shell/explorer/taskband.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/taskband.cpp?rev=65605&r1=65604&r2=65605&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/taskband.cpp      [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/taskband.cpp      [iso-8859-1] Thu Dec 11 
17:42:56 2014
@@ -272,55 +272,31 @@
 
     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)
-        {
-            m_Site->Release();
-        }
-
-        m_Site = NULL;
-        m_hWnd = NULL;
-
-        if (pUnkSite != NULL)
-        {
-            CComPtr<IOleWindow> 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);
-            }
-        }
-
-        return hRet;
+        hRet = IUnknown_GetWindow(pUnkSite, &hwndSite);
+        if (FAILED(hRet))
+        {
+            TRACE("Querying site window failed: 0x%x\n", hRet);
+            return hRet;
+        }
+
+        TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hwndSite);
+
+        HWND hwndTaskSwitch = CreateTaskSwitchWnd(hwndSite, m_Tray);
+        if (!hwndTaskSwitch)
+        {
+            ERR("CreateTaskSwitchWnd failed");
+            return E_FAIL;
+        }
+
+        m_Site = pUnkSite;
+        m_hWnd = hwndTaskSwitch;
+
+        return S_OK;
     }
 
     virtual HRESULT STDMETHODCALLTYPE GetSite(

Modified: trunk/reactos/base/shell/explorer/tbsite.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/tbsite.cpp?rev=65605&r1=65604&r2=65605&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/tbsite.cpp        [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/tbsite.cpp        [iso-8859-1] Thu Dec 11 
17:42:56 2014
@@ -350,23 +350,9 @@
 
     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);
     }


Reply via email to