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 ** ITaskBand ****************************************************************
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
,
36 public IPersistStream
,
37 public IWinEventHandler
,
38 public IOleCommandTarget
40 CComPtr
<ITrayWindow
> Tray
;
41 CComPtr
<IUnknown
> punkSite
;
54 virtual ~CTaskBand() { }
56 virtual HRESULT STDMETHODCALLTYPE
GetRebarBandID(
59 if (dwBandID
!= (DWORD
) -1)
61 if (pdwBandID
!= NULL
)
62 *pdwBandID
= dwBandID
;
70 /*****************************************************************************/
72 virtual HRESULT STDMETHODCALLTYPE
GetWindow(
76 /* NOTE: We have to return the tray window here so that ITaskBarClient
77 knows the parent window of the Rebar control it creates when
78 calling ITaskBarClient::SetDeskBarSite()! However, once we
79 created a window we return the task switch window! */
83 *phwnd
= Tray
->GetHWND();
85 TRACE("ITaskBand::GetWindow(0x%p->0x%p)\n", phwnd
, *phwnd
);
93 virtual HRESULT STDMETHODCALLTYPE
ContextSensitiveHelp(
96 /* FIXME: Implement */
100 virtual HRESULT STDMETHODCALLTYPE
ShowDW(
103 /* We don't do anything... */
107 virtual HRESULT STDMETHODCALLTYPE
CloseDW(
110 /* We don't do anything... */
114 virtual HRESULT STDMETHODCALLTYPE
ResizeBorderDW(
116 IUnknown
*punkToolbarSite
,
119 /* No need to implement this method */
123 virtual HRESULT STDMETHODCALLTYPE
GetBandInfo(
126 IN OUT DESKBANDINFO
*pdbi
)
128 TRACE("ITaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID
, dwViewMode
, pdbi
, hWnd
);
132 /* The task band never has a title */
133 pdbi
->dwMask
&= ~DBIM_TITLE
;
135 /* NOTE: We don't return DBIMF_UNDELETEABLE here, the band site will
136 handle us differently and add this flag for us. The reason for
137 this is future changes that might allow it to be deletable.
138 We want the band site to be in charge of this decision rather
140 /* FIXME: What about DBIMF_NOGRIPPER and DBIMF_ALWAYSGRIPPER */
141 pdbi
->dwModeFlags
= DBIMF_VARIABLEHEIGHT
;
143 if (dwViewMode
& DBIF_VIEWMODE_VERTICAL
)
145 pdbi
->ptIntegral
.y
= 1;
146 pdbi
->ptMinSize
.y
= 1;
147 /* FIXME: Get the button metrics from the task bar object!!! */
148 pdbi
->ptMinSize
.x
= (3 * GetSystemMetrics(SM_CXEDGE
) / 2) + /* FIXME: Might be wrong if only one column! */
149 GetSystemMetrics(SM_CXSIZE
) + (2 * GetSystemMetrics(SM_CXEDGE
)); /* FIXME: Min button size, query!!! */
153 pdbi
->ptMinSize
.y
= GetSystemMetrics(SM_CYSIZE
) + (2 * GetSystemMetrics(SM_CYEDGE
)); /* FIXME: Query */
154 pdbi
->ptIntegral
.y
= pdbi
->ptMinSize
.y
+ (3 * GetSystemMetrics(SM_CYEDGE
) / 2); /* FIXME: Query metrics */
155 /* We're not going to allow task bands where not even the minimum button size fits into the band */
156 pdbi
->ptMinSize
.x
= pdbi
->ptIntegral
.y
;
159 /* Ignored: pdbi->ptMaxSize.x */
160 pdbi
->ptMaxSize
.y
= -1;
162 /* FIXME: We should query the height from the task bar object!!! */
163 pdbi
->ptActual
.y
= GetSystemMetrics(SM_CYSIZE
) + (2 * GetSystemMetrics(SM_CYEDGE
));
165 /* Save the band ID for future use in case we need to check whether a given band
167 this->dwBandID
= dwBandID
;
169 TRACE("H: %d, Min: %d,%d, Integral.y: %d Actual: %d,%d\n", (dwViewMode
& DBIF_VIEWMODE_VERTICAL
) == 0,
170 pdbi
->ptMinSize
.x
, pdbi
->ptMinSize
.y
, pdbi
->ptIntegral
.y
,
171 pdbi
->ptActual
.x
, pdbi
->ptActual
.y
);
179 /*****************************************************************************/
180 // *** IOleCommandTarget methods ***
181 virtual HRESULT STDMETHODCALLTYPE
QueryStatus(const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
187 virtual HRESULT STDMETHODCALLTYPE
Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
189 if (IsEqualIID(*pguidCmdGroup
, IID_IBandSite
))
194 if (IsEqualIID(*pguidCmdGroup
, IID_IDeskBand
))
203 /*****************************************************************************/
205 virtual HRESULT STDMETHODCALLTYPE
SetClient(
206 IN IUnknown
*punkClient
)
208 TRACE("IDeskBar::SetClient(0x%p)\n", punkClient
);
212 virtual HRESULT STDMETHODCALLTYPE
GetClient(
213 OUT IUnknown
**ppunkClient
)
215 TRACE("IDeskBar::GetClient(0x%p)\n", ppunkClient
);
219 virtual HRESULT STDMETHODCALLTYPE
OnPosRectChangeDB(
222 TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc
, prc
->left
, prc
->top
, prc
->right
, prc
->bottom
);
223 if (prc
->bottom
- prc
->top
== 0)
229 /*****************************************************************************/
231 virtual HRESULT STDMETHODCALLTYPE
GetClassID(
234 TRACE("ITaskBand::GetClassID(0x%p)\n", pClassID
);
235 /* We're going to return the (internal!) CLSID of the task band interface */
236 *pClassID
= CLSID_ITaskBand
;
240 virtual HRESULT STDMETHODCALLTYPE
IsDirty()
242 /* The object hasn't changed since the last save! */
246 virtual HRESULT STDMETHODCALLTYPE
Load(
249 TRACE("ITaskBand::Load called\n");
254 virtual HRESULT STDMETHODCALLTYPE
Save(
262 virtual HRESULT STDMETHODCALLTYPE
GetSizeMax(
263 OUT ULARGE_INTEGER
*pcbSize
)
265 TRACE("ITaskBand::GetSizeMax called\n");
266 /* We don't need any space for the task band */
267 pcbSize
->QuadPart
= 0;
271 /*****************************************************************************/
273 virtual HRESULT STDMETHODCALLTYPE
SetSite(IUnknown
*pUnkSite
)
275 HRESULT hRet
= E_FAIL
;
277 TRACE("ITaskBand::SetSite(0x%p)\n", pUnkSite
);
279 /* Release the current site */
280 if (punkSite
!= NULL
)
288 if (pUnkSite
!= NULL
)
290 IOleWindow
*OleWindow
;
292 /* Check if the site supports IOleWindow */
293 hRet
= pUnkSite
->QueryInterface(IID_PPV_ARG(IOleWindow
, &OleWindow
));
296 HWND hWndParent
= NULL
;
298 hRet
= OleWindow
->GetWindow(
302 /* Attempt to create the task switch window */
304 TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hWndParent
);
305 hWnd
= CreateTaskSwitchWnd(hWndParent
, Tray
);
313 TRACE("CreateTaskSwitchWnd() failed!\n");
314 OleWindow
->Release();
319 OleWindow
->Release();
322 TRACE("Querying IOleWindow failed: 0x%x\n", hRet
);
328 virtual HRESULT STDMETHODCALLTYPE
GetSite(
332 TRACE("ITaskBand::GetSite(0x%p,0x%p)\n", riid
, ppvSite
);
334 if (punkSite
!= NULL
)
336 return punkSite
->QueryInterface(riid
, ppvSite
);
343 /*****************************************************************************/
345 virtual HRESULT STDMETHODCALLTYPE
ProcessMessage(
350 OUT LRESULT
*plrResult
)
352 TRACE("ITaskBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd
, uMsg
, wParam
, lParam
, plrResult
);
356 virtual HRESULT STDMETHODCALLTYPE
ContainsWindow(
362 TRACE("ITaskBand::ContainsWindow(0x%p) returns S_OK\n", hWnd
);
369 virtual HRESULT STDMETHODCALLTYPE
OnWinEvent(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*theResult
)
375 virtual HRESULT STDMETHODCALLTYPE
IsWindowOwner(HWND hWnd
)
377 return (hWnd
== this->hWnd
) ? S_OK
: S_FALSE
;
380 /*****************************************************************************/
382 HRESULT STDMETHODCALLTYPE
_Init(IN OUT ITrayWindow
*tray
)
385 dwBandID
= (DWORD
) -1;
389 DECLARE_NOT_AGGREGATABLE(CTaskBand
)
391 DECLARE_PROTECT_FINAL_CONSTRUCT()
392 BEGIN_COM_MAP(CTaskBand
)
393 COM_INTERFACE_ENTRY2_IID(IID_IOleWindow
, IOleWindow
, IDeskBand
)
394 COM_INTERFACE_ENTRY_IID(IID_IDeskBand
, IDeskBand
)
395 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite
, IObjectWithSite
)
396 COM_INTERFACE_ENTRY_IID(IID_IPersist
, IPersist
)
397 COM_INTERFACE_ENTRY_IID(IID_IPersistStream
, IPersistStream
)
398 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler
, IWinEventHandler
)
399 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget
, IOleCommandTarget
)
403 ITaskBand
* CreateTaskBand(IN OUT ITrayWindow
*Tray
)
407 CTaskBand
* tb
= new CComObject
<CTaskBand
>();
414 hr
= tb
->_Init(Tray
);
416 if (FAILED_UNEXPECTEDLY(hr
))