4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 /*****************************************************************************
24 ** CTaskBand ****************************************************************
25 *****************************************************************************/
27 const GUID CLSID_ITaskBand
= { 0x68284FAA, 0x6A48, 0x11D0, { 0x8C, 0x78, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xB4 } };
30 public CComCoClass
<CTaskBand
>,
31 public CComObjectRootEx
<CComMultiThreadModelNoCS
>,
32 public IObjectWithSite
,
35 public IPersistStream
,
36 public IWinEventHandler
,
37 public IOleCommandTarget
39 CComPtr
<ITrayWindow
> m_Tray
;
40 CComPtr
<IUnknown
> m_Site
;
41 CComPtr
<IUnknown
> m_TasksWnd
;
51 virtual ~CTaskBand() { }
53 /*****************************************************************************/
55 virtual HRESULT STDMETHODCALLTYPE
GetWindow(OUT HWND
*phwnd
)
65 virtual HRESULT STDMETHODCALLTYPE
ContextSensitiveHelp(
68 /* FIXME: Implement */
72 virtual HRESULT STDMETHODCALLTYPE
ShowDW(
75 /* We don't do anything... */
79 virtual HRESULT STDMETHODCALLTYPE
CloseDW(
82 /* We don't do anything... */
86 virtual HRESULT STDMETHODCALLTYPE
ResizeBorderDW(
88 IUnknown
*punkToolbarSite
,
91 /* No need to implement this method */
95 virtual HRESULT STDMETHODCALLTYPE
GetBandInfo(
98 IN OUT DESKBANDINFO
*pdbi
)
100 TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID
, dwViewMode
, pdbi
, m_hWnd
);
104 HWND hwndToolbar
= ::GetWindow(m_hWnd
, GW_CHILD
);
106 /* The task band never has a title */
107 pdbi
->dwMask
&= ~DBIM_TITLE
;
109 /* NOTE: We don't return DBIMF_UNDELETEABLE here, the band site will
110 handle us differently and add this flag for us. The reason for
111 this is future changes that might allow it to be deletable.
112 We want the band site to be in charge of this decision rather
114 /* FIXME: What about DBIMF_NOGRIPPER and DBIMF_ALWAYSGRIPPER */
115 pdbi
->dwModeFlags
= DBIMF_VARIABLEHEIGHT
;
117 /* Obtain the button size, to be used as the minimum size */
118 DWORD size
= SendMessageW(hwndToolbar
, TB_GETBUTTONSIZE
, 0, 0);
119 pdbi
->ptMinSize
.x
= 0;
120 pdbi
->ptMinSize
.y
= GET_Y_LPARAM(size
);
122 if (dwViewMode
& DBIF_VIEWMODE_VERTICAL
)
124 pdbi
->ptIntegral
.x
= 0;
125 pdbi
->ptIntegral
.y
= 1;
129 pdbi
->ptIntegral
.x
= 0;
130 pdbi
->ptIntegral
.y
= GET_Y_LPARAM(size
);
133 /* Ignored: pdbi->ptMaxSize.x */
134 pdbi
->ptMaxSize
.y
= -1;
137 ::GetWindowRect(hwndToolbar
, &rcToolbar
);
138 /* FIXME: We should query the height from the task bar object!!! */
139 pdbi
->ptActual
.x
= rcToolbar
.right
- rcToolbar
.left
;
140 pdbi
->ptActual
.y
= rcToolbar
.bottom
- rcToolbar
.top
;
142 TRACE("H: %d, Min: %d,%d, Integral.y: %d Actual: %d,%d\n", (dwViewMode
& DBIF_VIEWMODE_VERTICAL
) == 0,
143 pdbi
->ptMinSize
.x
, pdbi
->ptMinSize
.y
, pdbi
->ptIntegral
.y
,
144 pdbi
->ptActual
.x
, pdbi
->ptActual
.y
);
152 /*****************************************************************************/
153 // *** IOleCommandTarget methods ***
154 virtual HRESULT STDMETHODCALLTYPE
QueryStatus(const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
160 virtual HRESULT STDMETHODCALLTYPE
Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
162 if (IsEqualIID(*pguidCmdGroup
, IID_IBandSite
))
167 if (IsEqualIID(*pguidCmdGroup
, IID_IDeskBand
))
176 /*****************************************************************************/
178 virtual HRESULT STDMETHODCALLTYPE
SetClient(
179 IN IUnknown
*punkClient
)
181 TRACE("IDeskBar::SetClient(0x%p)\n", punkClient
);
185 virtual HRESULT STDMETHODCALLTYPE
GetClient(
186 OUT IUnknown
**ppunkClient
)
188 TRACE("IDeskBar::GetClient(0x%p)\n", ppunkClient
);
192 virtual HRESULT STDMETHODCALLTYPE
OnPosRectChangeDB(
195 TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc
, prc
->left
, prc
->top
, prc
->right
, prc
->bottom
);
196 if (prc
->bottom
- prc
->top
== 0)
202 /*****************************************************************************/
204 virtual HRESULT STDMETHODCALLTYPE
GetClassID(
207 TRACE("CTaskBand::GetClassID(0x%p)\n", pClassID
);
208 /* We're going to return the (internal!) CLSID of the task band interface */
209 *pClassID
= CLSID_ITaskBand
;
213 virtual HRESULT STDMETHODCALLTYPE
IsDirty()
215 /* The object hasn't changed since the last save! */
219 virtual HRESULT STDMETHODCALLTYPE
Load(
222 TRACE("CTaskBand::Load called\n");
227 virtual HRESULT STDMETHODCALLTYPE
Save(
235 virtual HRESULT STDMETHODCALLTYPE
GetSizeMax(
236 OUT ULARGE_INTEGER
*pcbSize
)
238 TRACE("CTaskBand::GetSizeMax called\n");
239 /* We don't need any space for the task band */
240 pcbSize
->QuadPart
= 0;
244 /*****************************************************************************/
246 virtual HRESULT STDMETHODCALLTYPE
SetSite(IUnknown
*pUnkSite
)
251 TRACE("CTaskBand::SetSite(0x%p)\n", pUnkSite
);
253 hRet
= IUnknown_GetWindow(pUnkSite
, &hwndSite
);
254 if (FAILED_UNEXPECTEDLY(hRet
))
257 TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hwndSite
);
259 hRet
= CTaskSwitchWnd_CreateInstance(hwndSite
, m_Tray
, IID_PPV_ARG(IUnknown
, &m_TasksWnd
));
260 if (FAILED_UNEXPECTEDLY(hRet
))
263 hRet
= IUnknown_GetWindow(m_TasksWnd
, &m_hWnd
);
264 if (FAILED_UNEXPECTEDLY(hRet
))
272 virtual HRESULT STDMETHODCALLTYPE
GetSite(
276 TRACE("CTaskBand::GetSite(0x%p,0x%p)\n", riid
, ppvSite
);
280 return m_Site
->QueryInterface(riid
, ppvSite
);
287 /*****************************************************************************/
289 virtual HRESULT STDMETHODCALLTYPE
ProcessMessage(
294 OUT LRESULT
*plrResult
)
296 TRACE("CTaskBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd
, uMsg
, wParam
, lParam
, plrResult
);
300 virtual HRESULT STDMETHODCALLTYPE
ContainsWindow(
303 if (hWnd
== m_hWnd
||
304 IsChild(m_hWnd
, hWnd
))
306 TRACE("CTaskBand::ContainsWindow(0x%p) returns S_OK\n", hWnd
);
313 virtual HRESULT STDMETHODCALLTYPE
OnWinEvent(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*theResult
)
319 virtual HRESULT STDMETHODCALLTYPE
IsWindowOwner(HWND hWnd
)
321 return (hWnd
== m_hWnd
) ? S_OK
: S_FALSE
;
324 /*****************************************************************************/
326 HRESULT STDMETHODCALLTYPE
Initialize(IN OUT ITrayWindow
*tray
, HWND hWndStartButton
)
332 DECLARE_NOT_AGGREGATABLE(CTaskBand
)
334 DECLARE_PROTECT_FINAL_CONSTRUCT()
335 BEGIN_COM_MAP(CTaskBand
)
336 COM_INTERFACE_ENTRY2_IID(IID_IOleWindow
, IOleWindow
, IDeskBand
)
337 COM_INTERFACE_ENTRY_IID(IID_IDeskBand
, IDeskBand
)
338 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite
, IObjectWithSite
)
339 COM_INTERFACE_ENTRY_IID(IID_IPersist
, IPersist
)
340 COM_INTERFACE_ENTRY_IID(IID_IPersistStream
, IPersistStream
)
341 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler
, IWinEventHandler
)
342 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget
, IOleCommandTarget
)
346 HRESULT
CTaskBand_CreateInstance(IN ITrayWindow
*Tray
, HWND hWndStartButton
, REFIID riid
, void **ppv
)
348 return ShellObjectCreatorInit
<CTaskBand
>(Tray
, hWndStartButton
, riid
, ppv
);