Skip to content

Commit

Permalink
[EXPLORER]: Simplify the creation of the tray band site and the tasks…
Browse files Browse the repository at this point in the history
… band.

- CTrayBandSite: Rename its constructor to CTrayBandSite_CreateInstance. Let the CTrayWindow create the CTasksBand and pass it to the constructor. Use a standard com interface to see if the tasks band was added while loading and don't use an explorer specific interface for it. Make CTrayBandSite::_Init a bit clearer.
- CTrayWindow: Implement the IOleWindow interface and create the CTaskBand before creating the CTrayBandSite. Then use standard com interfaces to get their respective HRND.
- CTaskBand: Rename its constructor to CTaskBand_CreateInstance. Remove a hack that was using its IOleWindow to act like the IOleWindow of the CTrayWindow during the creation of the CTrayBandSite. This is possible since the IOleWindow of the CTrayWindow is passed to the SetDeskBarSite method of CTrayBandSite.

svn path=/trunk/; revision=74224
  • Loading branch information
yagoulas committed Mar 23, 2017
1 parent 0cd0319 commit b8b7eed
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 209 deletions.
33 changes: 3 additions & 30 deletions reactos/base/shell/explorer/precomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,32 +232,8 @@ ShowCustomizeNotifyIcons(HINSTANCE, HWND);
* taskband.cpp
*/

/* Internal Task Band CLSID */
extern const GUID CLSID_ITaskBand;

#define INTERFACE ITaskBand
DECLARE_INTERFACE_(ITaskBand, IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG, AddRef) (THIS) PURE;
STDMETHOD_(ULONG, Release) (THIS) PURE;
/*** ITaskBand methods ***/
STDMETHOD_(HRESULT, GetRebarBandID)(THIS_ DWORD *pdwBandID) PURE;
};
#undef INTERFACE

#if defined(COBJMACROS)
/*** IUnknown methods ***/
#define ITaskBand_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define ITaskBand_AddRef(p) (p)->lpVtbl->AddRef(p)
#define ITaskBand_Release(p) (p)->lpVtbl->Release(p)
/*** ITaskBand methods ***/
#define ITaskBand_GetRebarBandID(p,a) (p)->lpVtbl->GetRebarBandID(p,a)
#endif

ITaskBand *
CreateTaskBand(IN OUT ITrayWindow *Tray);
extern const GUID CLSID_ITaskBand; /* Internal Task Band CLSID */
HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, REFIID riid, void **ppv);

/*
* tbsite.cpp
Expand Down Expand Up @@ -296,10 +272,7 @@ DECLARE_INTERFACE_(ITrayBandSite, IUnknown)
#define ITrayBandSite_Lock(p,a) (p)->lpVtbl->Lock(p,a)
#endif

ITrayBandSite *
CreateTrayBandSite(IN OUT ITrayWindow *Tray,
OUT HWND *phWndRebar,
OUT HWND *phWndTaskSwitch);
HRESULT CTrayBandSite_CreateInstance(IN ITrayWindow *tray, IN IDeskBand* pTaskBand, OUT ITrayBandSite** pBandSite);

/*
* startmnu.cpp
Expand Down
78 changes: 19 additions & 59 deletions reactos/base/shell/explorer/taskband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "precomp.h"

/*****************************************************************************
** ITaskBand ****************************************************************
** CTaskBand ****************************************************************
*****************************************************************************/

const GUID CLSID_ITaskBand = { 0x68284FAA, 0x6A48, 0x11D0, { 0x8C, 0x78, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xB4 } };
Expand All @@ -30,7 +30,6 @@ class CTaskBand :
public CComCoClass<CTaskBand>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IObjectWithSite,
public ITaskBand,
public IDeskBand,
public IDeskBar,
public IPersistStream,
Expand All @@ -53,41 +52,16 @@ class CTaskBand :

virtual ~CTaskBand() { }

virtual HRESULT STDMETHODCALLTYPE GetRebarBandID(
OUT DWORD *pdwBandID)
{
if (m_BandID != (DWORD) -1)
{
if (pdwBandID != NULL)
*pdwBandID = m_BandID;

return S_OK;
}

return E_FAIL;
}

/*****************************************************************************/

virtual HRESULT STDMETHODCALLTYPE GetWindow(
OUT HWND *phwnd)
virtual HRESULT STDMETHODCALLTYPE GetWindow(OUT HWND *phwnd)
{

/* NOTE: We have to return the tray window here so that ITaskBarClient
knows the parent window of the Rebar control it creates when
calling ITaskBarClient::SetDeskBarSite()! However, once we
created a window we return the task switch window! */
if (m_hWnd != NULL)
*phwnd = m_hWnd;
else
*phwnd = m_Tray->GetHWND();

TRACE("ITaskBand::GetWindow(0x%p->0x%p)\n", phwnd, *phwnd);

if (*phwnd != NULL)
return S_OK;

return E_FAIL;
if (!m_hWnd)
return E_FAIL;
if (!phwnd)
return E_INVALIDARG;
*phwnd = m_hWnd;
return S_OK;
}

virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(
Expand Down Expand Up @@ -125,7 +99,7 @@ class CTaskBand :
IN DWORD dwViewMode,
IN OUT DESKBANDINFO *pdbi)
{
TRACE("ITaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd);
TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd);

if (m_hWnd != NULL)
{
Expand Down Expand Up @@ -231,7 +205,7 @@ class CTaskBand :
virtual HRESULT STDMETHODCALLTYPE GetClassID(
OUT CLSID *pClassID)
{
TRACE("ITaskBand::GetClassID(0x%p)\n", pClassID);
TRACE("CTaskBand::GetClassID(0x%p)\n", pClassID);
/* We're going to return the (internal!) CLSID of the task band interface */
*pClassID = CLSID_ITaskBand;
return S_OK;
Expand All @@ -246,7 +220,7 @@ class CTaskBand :
virtual HRESULT STDMETHODCALLTYPE Load(
IN IStream *pStm)
{
TRACE("ITaskBand::Load called\n");
TRACE("CTaskBand::Load called\n");
/* Nothing to do */
return S_OK;
}
Expand All @@ -262,7 +236,7 @@ class CTaskBand :
virtual HRESULT STDMETHODCALLTYPE GetSizeMax(
OUT ULARGE_INTEGER *pcbSize)
{
TRACE("ITaskBand::GetSizeMax called\n");
TRACE("CTaskBand::GetSizeMax called\n");
/* We don't need any space for the task band */
pcbSize->QuadPart = 0;
return S_OK;
Expand All @@ -275,7 +249,7 @@ class CTaskBand :
HRESULT hRet;
HWND hwndSite;

TRACE("ITaskBand::SetSite(0x%p)\n", pUnkSite);
TRACE("CTaskBand::SetSite(0x%p)\n", pUnkSite);

hRet = IUnknown_GetWindow(pUnkSite, &hwndSite);
if (FAILED(hRet))
Expand Down Expand Up @@ -303,7 +277,7 @@ class CTaskBand :
IN REFIID riid,
OUT VOID **ppvSite)
{
TRACE("ITaskBand::GetSite(0x%p,0x%p)\n", riid, ppvSite);
TRACE("CTaskBand::GetSite(0x%p,0x%p)\n", riid, ppvSite);

if (m_Site != NULL)
{
Expand All @@ -323,7 +297,7 @@ class CTaskBand :
IN LPARAM lParam,
OUT LRESULT *plrResult)
{
TRACE("ITaskBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd, uMsg, wParam, lParam, plrResult);
TRACE("CTaskBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd, uMsg, wParam, lParam, plrResult);
return E_NOTIMPL;
}

Expand All @@ -333,7 +307,7 @@ class CTaskBand :
if (hWnd == m_hWnd ||
IsChild(m_hWnd, hWnd))
{
TRACE("ITaskBand::ContainsWindow(0x%p) returns S_OK\n", hWnd);
TRACE("CTaskBand::ContainsWindow(0x%p) returns S_OK\n", hWnd);
return S_OK;
}

Expand All @@ -353,7 +327,7 @@ class CTaskBand :

/*****************************************************************************/

HRESULT STDMETHODCALLTYPE _Init(IN OUT ITrayWindow *tray)
HRESULT STDMETHODCALLTYPE Initialize(IN OUT ITrayWindow *tray)
{
m_Tray = tray;
m_BandID = (DWORD) -1;
Expand All @@ -374,21 +348,7 @@ class CTaskBand :
END_COM_MAP()
};

ITaskBand * CreateTaskBand(IN OUT ITrayWindow *Tray)
HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, REFIID riid, void **ppv)
{
HRESULT hr;

CTaskBand * tb = new CComObject<CTaskBand>();

if (!tb)
return NULL;

hr = tb->AddRef();

hr = tb->_Init(Tray);

if (FAILED_UNEXPECTEDLY(hr))
tb->Release();

return tb;
return ShellObjectCreatorInit<CTaskBand>(Tray, riid, ppv);
}

0 comments on commit b8b7eed

Please sign in to comment.