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
;
50 virtual ~CTaskBand() { }
52 /*****************************************************************************/
54 virtual HRESULT STDMETHODCALLTYPE
GetWindow(OUT HWND
*phwnd
)
64 virtual HRESULT STDMETHODCALLTYPE
ContextSensitiveHelp(
67 /* FIXME: Implement */
71 virtual HRESULT STDMETHODCALLTYPE
ShowDW(
74 /* We don't do anything... */
78 virtual HRESULT STDMETHODCALLTYPE
CloseDW(
81 /* We don't do anything... */
85 virtual HRESULT STDMETHODCALLTYPE
ResizeBorderDW(
87 IUnknown
*punkToolbarSite
,
90 /* No need to implement this method */
94 virtual HRESULT STDMETHODCALLTYPE
GetBandInfo(
97 IN OUT DESKBANDINFO
*pdbi
)
99 TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID
, dwViewMode
, pdbi
, m_hWnd
);
103 HWND hwndToolbar
= ::GetWindow(m_hWnd
, GW_CHILD
);
105 /* The task band never has a title */
106 pdbi
->dwMask
&= ~DBIM_TITLE
;
108 /* NOTE: We don't return DBIMF_UNDELETEABLE here, the band site will
109 handle us differently and add this flag for us. The reason for
110 this is future changes that might allow it to be deletable.
111 We want the band site to be in charge of this decision rather
113 /* FIXME: What about DBIMF_NOGRIPPER and DBIMF_ALWAYSGRIPPER */
114 pdbi
->dwModeFlags
= DBIMF_VARIABLEHEIGHT
;
116 /* Obtain the button size, to be used as the minimum size */
117 DWORD size
= SendMessageW(hwndToolbar
, TB_GETBUTTONSIZE
, 0, 0);
118 pdbi
->ptMinSize
.x
= 0;
119 pdbi
->ptMinSize
.y
= GET_Y_LPARAM(size
);
121 if (dwViewMode
& DBIF_VIEWMODE_VERTICAL
)
123 pdbi
->ptIntegral
.x
= 0;
124 pdbi
->ptIntegral
.y
= 1;
128 pdbi
->ptIntegral
.x
= 0;
129 pdbi
->ptIntegral
.y
= GET_Y_LPARAM(size
);
132 /* Ignored: pdbi->ptMaxSize.x */
133 pdbi
->ptMaxSize
.y
= -1;
136 ::GetWindowRect(hwndToolbar
, &rcToolbar
);
137 /* FIXME: We should query the height from the task bar object!!! */
138 pdbi
->ptActual
.x
= rcToolbar
.right
- rcToolbar
.left
;
139 pdbi
->ptActual
.y
= rcToolbar
.bottom
- rcToolbar
.top
;
141 TRACE("H: %d, Min: %d,%d, Integral.y: %d Actual: %d,%d\n", (dwViewMode
& DBIF_VIEWMODE_VERTICAL
) == 0,
142 pdbi
->ptMinSize
.x
, pdbi
->ptMinSize
.y
, pdbi
->ptIntegral
.y
,
143 pdbi
->ptActual
.x
, pdbi
->ptActual
.y
);
151 /*****************************************************************************/
152 // *** IOleCommandTarget methods ***
153 virtual HRESULT STDMETHODCALLTYPE
QueryStatus(const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
159 virtual HRESULT STDMETHODCALLTYPE
Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
161 if (IsEqualIID(*pguidCmdGroup
, IID_IBandSite
))
166 if (IsEqualIID(*pguidCmdGroup
, IID_IDeskBand
))
175 /*****************************************************************************/
177 virtual HRESULT STDMETHODCALLTYPE
SetClient(
178 IN IUnknown
*punkClient
)
180 TRACE("IDeskBar::SetClient(0x%p)\n", punkClient
);
184 virtual HRESULT STDMETHODCALLTYPE
GetClient(
185 OUT IUnknown
**ppunkClient
)
187 TRACE("IDeskBar::GetClient(0x%p)\n", ppunkClient
);
191 virtual HRESULT STDMETHODCALLTYPE
OnPosRectChangeDB(
194 TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc
, prc
->left
, prc
->top
, prc
->right
, prc
->bottom
);
195 if (prc
->bottom
- prc
->top
== 0)
201 /*****************************************************************************/
203 virtual HRESULT STDMETHODCALLTYPE
GetClassID(
206 TRACE("CTaskBand::GetClassID(0x%p)\n", pClassID
);
207 /* We're going to return the (internal!) CLSID of the task band interface */
208 *pClassID
= CLSID_ITaskBand
;
212 virtual HRESULT STDMETHODCALLTYPE
IsDirty()
214 /* The object hasn't changed since the last save! */
218 virtual HRESULT STDMETHODCALLTYPE
Load(
221 TRACE("CTaskBand::Load called\n");
226 virtual HRESULT STDMETHODCALLTYPE
Save(
234 virtual HRESULT STDMETHODCALLTYPE
GetSizeMax(
235 OUT ULARGE_INTEGER
*pcbSize
)
237 TRACE("CTaskBand::GetSizeMax called\n");
238 /* We don't need any space for the task band */
239 pcbSize
->QuadPart
= 0;
243 /*****************************************************************************/
245 virtual HRESULT STDMETHODCALLTYPE
SetSite(IUnknown
*pUnkSite
)
250 TRACE("CTaskBand::SetSite(0x%p)\n", pUnkSite
);
252 hRet
= IUnknown_GetWindow(pUnkSite
, &hwndSite
);
255 TRACE("Querying site window failed: 0x%x\n", hRet
);
259 TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hwndSite
);
261 HWND hwndTaskSwitch
= CreateTaskSwitchWnd(hwndSite
, m_Tray
);
264 ERR("CreateTaskSwitchWnd failed");
269 m_hWnd
= hwndTaskSwitch
;
274 virtual HRESULT STDMETHODCALLTYPE
GetSite(
278 TRACE("CTaskBand::GetSite(0x%p,0x%p)\n", riid
, ppvSite
);
282 return m_Site
->QueryInterface(riid
, ppvSite
);
289 /*****************************************************************************/
291 virtual HRESULT STDMETHODCALLTYPE
ProcessMessage(
296 OUT LRESULT
*plrResult
)
298 TRACE("CTaskBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd
, uMsg
, wParam
, lParam
, plrResult
);
302 virtual HRESULT STDMETHODCALLTYPE
ContainsWindow(
305 if (hWnd
== m_hWnd
||
306 IsChild(m_hWnd
, hWnd
))
308 TRACE("CTaskBand::ContainsWindow(0x%p) returns S_OK\n", hWnd
);
315 virtual HRESULT STDMETHODCALLTYPE
OnWinEvent(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*theResult
)
321 virtual HRESULT STDMETHODCALLTYPE
IsWindowOwner(HWND hWnd
)
323 return (hWnd
== m_hWnd
) ? S_OK
: S_FALSE
;
326 /*****************************************************************************/
328 HRESULT STDMETHODCALLTYPE
Initialize(IN OUT ITrayWindow
*tray
, HWND hWndStartButton
)
334 DECLARE_NOT_AGGREGATABLE(CTaskBand
)
336 DECLARE_PROTECT_FINAL_CONSTRUCT()
337 BEGIN_COM_MAP(CTaskBand
)
338 COM_INTERFACE_ENTRY2_IID(IID_IOleWindow
, IOleWindow
, IDeskBand
)
339 COM_INTERFACE_ENTRY_IID(IID_IDeskBand
, IDeskBand
)
340 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite
, IObjectWithSite
)
341 COM_INTERFACE_ENTRY_IID(IID_IPersist
, IPersist
)
342 COM_INTERFACE_ENTRY_IID(IID_IPersistStream
, IPersistStream
)
343 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler
, IWinEventHandler
)
344 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget
, IOleCommandTarget
)
348 HRESULT
CTaskBand_CreateInstance(IN ITrayWindow
*Tray
, HWND hWndStartButton
, REFIID riid
, void **ppv
)
350 return ShellObjectCreatorInit
<CTaskBand
>(Tray
, hWndStartButton
, riid
, ppv
);