ReactOS 0.4.15-dev-7942-gd23573b
taskband.cpp
Go to the documentation of this file.
1/*
2 * ReactOS Explorer
3 *
4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "precomp.h"
22
23/*****************************************************************************
24 ** CTaskBand ****************************************************************
25 *****************************************************************************/
26
27const GUID CLSID_ITaskBand = { 0x68284FAA, 0x6A48, 0x11D0, { 0x8C, 0x78, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xB4 } };
28
29class CTaskBand :
30 public CComCoClass<CTaskBand>,
31 public CComObjectRootEx<CComMultiThreadModelNoCS>,
32 public IObjectWithSite,
33 public IDeskBand,
34 public IDeskBar,
35 public IPersistStream,
36 public IWinEventHandler,
38{
42
44
45public:
48 {
49 }
50
51 virtual ~CTaskBand() { }
52
53 /*****************************************************************************/
54
56 {
57 if (!m_hWnd)
58 return E_FAIL;
59 if (!phwnd)
60 return E_INVALIDARG;
61 *phwnd = m_hWnd;
62 return S_OK;
63 }
64
66 IN BOOL fEnterMode)
67 {
68 /* FIXME: Implement */
69 return E_NOTIMPL;
70 }
71
73 IN BOOL bShow)
74 {
75 /* We don't do anything... */
76 return S_OK;
77 }
78
81 {
82 /* We don't do anything... */
83 return S_OK;
84 }
85
87 LPCRECT prcBorder,
88 IUnknown *punkToolbarSite,
89 BOOL fReserved)
90 {
91 /* No need to implement this method */
92 return E_NOTIMPL;
93 }
94
96 IN DWORD dwBandID,
97 IN DWORD dwViewMode,
98 IN OUT DESKBANDINFO *pdbi)
99 {
100 TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd);
101
102 if (m_hWnd != NULL)
103 {
104 HWND hwndToolbar = ::GetWindow(m_hWnd, GW_CHILD);
105
106 /* The task band never has a title */
107 pdbi->dwMask &= ~DBIM_TITLE;
108
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
113 the band itself! */
114 /* FIXME: What about DBIMF_NOGRIPPER and DBIMF_ALWAYSGRIPPER */
115 pdbi->dwModeFlags = DBIMF_VARIABLEHEIGHT;
116
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);
121
122 if (dwViewMode & DBIF_VIEWMODE_VERTICAL)
123 {
124 pdbi->ptIntegral.x = 0;
125 pdbi->ptIntegral.y = 1;
126 }
127 else
128 {
129 pdbi->ptIntegral.x = 0;
130 pdbi->ptIntegral.y = GET_Y_LPARAM(size);
131 }
132
133 /* Ignored: pdbi->ptMaxSize.x */
134 pdbi->ptMaxSize.y = -1;
135
136 RECT rcToolbar;
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;
141
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);
145
146 return S_OK;
147 }
148
149 return E_FAIL;
150 }
151
152 /*****************************************************************************/
153 // *** IOleCommandTarget methods ***
154 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
155 {
157 return E_NOTIMPL;
158 }
159
160 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
161 {
162 if (IsEqualIID(*pguidCmdGroup, IID_IBandSite))
163 {
164 return S_OK;
165 }
166
167 if (IsEqualIID(*pguidCmdGroup, IID_IDeskBand))
168 {
169 return S_OK;
170 }
171
173 return E_NOTIMPL;
174 }
175
176 /*****************************************************************************/
177
179 IN IUnknown *punkClient)
180 {
181 TRACE("IDeskBar::SetClient(0x%p)\n", punkClient);
182 return E_NOTIMPL;
183 }
184
186 OUT IUnknown **ppunkClient)
187 {
188 TRACE("IDeskBar::GetClient(0x%p)\n", ppunkClient);
189 return E_NOTIMPL;
190 }
191
193 IN RECT *prc)
194 {
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)
197 return S_OK;
198
199 return S_FALSE;
200 }
201
202 /*****************************************************************************/
203
205 OUT CLSID *pClassID)
206 {
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;
210 return S_OK;
211 }
212
214 {
215 /* The object hasn't changed since the last save! */
216 return S_FALSE;
217 }
218
220 IN IStream *pStm)
221 {
222 TRACE("CTaskBand::Load called\n");
223 /* Nothing to do */
224 return S_OK;
225 }
226
228 IN IStream *pStm,
229 IN BOOL fClearDirty)
230 {
231 /* Nothing to do */
232 return S_OK;
233 }
234
236 OUT ULARGE_INTEGER *pcbSize)
237 {
238 TRACE("CTaskBand::GetSizeMax called\n");
239 /* We don't need any space for the task band */
240 pcbSize->QuadPart = 0;
241 return S_OK;
242 }
243
244 /*****************************************************************************/
245
247 {
248 HRESULT hRet;
249 HWND hwndSite;
250
251 TRACE("CTaskBand::SetSite(0x%p)\n", pUnkSite);
252
253 hRet = IUnknown_GetWindow(pUnkSite, &hwndSite);
254 if (FAILED_UNEXPECTEDLY(hRet))
255 return hRet;
256
257 TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hwndSite);
258
260 if (FAILED_UNEXPECTEDLY(hRet))
261 return hRet;
262
264 if (FAILED_UNEXPECTEDLY(hRet))
265 return hRet;
266
267 m_Site = pUnkSite;
268
269 return S_OK;
270 }
271
273 IN REFIID riid,
274 OUT VOID **ppvSite)
275 {
276 TRACE("CTaskBand::GetSite(0x%p,0x%p)\n", riid, ppvSite);
277
278 if (m_Site != NULL)
279 {
280 return m_Site->QueryInterface(riid, ppvSite);
281 }
282
283 *ppvSite = NULL;
284 return E_FAIL;
285 }
286
287 /*****************************************************************************/
288
290 IN HWND hWnd,
291 IN UINT uMsg,
294 OUT LRESULT *plrResult)
295 {
296 TRACE("CTaskBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd, uMsg, wParam, lParam, plrResult);
297 return E_NOTIMPL;
298 }
299
301 IN HWND hWnd)
302 {
303 if (hWnd == m_hWnd ||
305 {
306 TRACE("CTaskBand::ContainsWindow(0x%p) returns S_OK\n", hWnd);
307 return S_OK;
308 }
309
310 return S_FALSE;
311 }
312
314 {
315 //UNIMPLEMENTED;
316 return E_NOTIMPL;
317 }
318
320 {
321 return (hWnd == m_hWnd) ? S_OK : S_FALSE;
322 }
323
324 /*****************************************************************************/
325
326 HRESULT STDMETHODCALLTYPE Initialize(IN OUT ITrayWindow *tray, HWND hWndStartButton)
327 {
328 m_Tray = tray;
329 return S_OK;
330 }
331
333
337 COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
341 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
342 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
344};
345
346HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, HWND hWndStartButton, REFIID riid, void **ppv)
347{
348 return ShellObjectCreatorInit<CTaskBand>(Tray, hWndStartButton, riid, ppv);
349}
HWND hWnd
Definition: settings.c:17
HRESULT CTaskSwitchWnd_CreateInstance(IN HWND hWndParent, IN OUT ITrayWindow *Tray, REFIID riid, void **ppv)
Definition: taskswnd.cpp:2026
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define UNIMPLEMENTED
Definition: debug.h:115
virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
Definition: taskband.cpp:154
CComPtr< IUnknown > m_Site
Definition: taskband.cpp:40
virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
Definition: taskband.cpp:86
virtual HRESULT STDMETHODCALLTYPE Load(IN IStream *pStm)
Definition: taskband.cpp:219
virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(IN RECT *prc)
Definition: taskband.cpp:192
virtual HRESULT STDMETHODCALLTYPE CloseDW(IN DWORD dwReserved)
Definition: taskband.cpp:79
HWND m_hWnd
Definition: taskband.cpp:43
virtual HRESULT STDMETHODCALLTYPE SetClient(IN IUnknown *punkClient)
Definition: taskband.cpp:178
virtual HRESULT STDMETHODCALLTYPE ShowDW(IN BOOL bShow)
Definition: taskband.cpp:72
virtual HRESULT STDMETHODCALLTYPE ContainsWindow(IN HWND hWnd)
Definition: taskband.cpp:300
virtual ~CTaskBand()
Definition: taskband.cpp:51
virtual HRESULT STDMETHODCALLTYPE Save(IN IStream *pStm, IN BOOL fClearDirty)
Definition: taskband.cpp:227
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(IN BOOL fEnterMode)
Definition: taskband.cpp:65
virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
Definition: taskband.cpp:160
virtual HRESULT STDMETHODCALLTYPE IsDirty()
Definition: taskband.cpp:213
virtual HRESULT STDMETHODCALLTYPE GetSizeMax(OUT ULARGE_INTEGER *pcbSize)
Definition: taskband.cpp:235
CComPtr< ITrayWindow > m_Tray
Definition: taskband.cpp:39
virtual HRESULT STDMETHODCALLTYPE GetClient(OUT IUnknown **ppunkClient)
Definition: taskband.cpp:185
virtual HRESULT STDMETHODCALLTYPE GetWindow(OUT HWND *phwnd)
Definition: taskband.cpp:55
virtual HRESULT STDMETHODCALLTYPE GetClassID(OUT CLSID *pClassID)
Definition: taskband.cpp:204
CComPtr< IUnknown > m_TasksWnd
Definition: taskband.cpp:41
virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd)
Definition: taskband.cpp:319
virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
Definition: taskband.cpp:313
virtual HRESULT STDMETHODCALLTYPE GetBandInfo(IN DWORD dwBandID, IN DWORD dwViewMode, IN OUT DESKBANDINFO *pdbi)
Definition: taskband.cpp:95
virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite)
Definition: taskband.cpp:246
virtual HRESULT STDMETHODCALLTYPE ProcessMessage(IN HWND hWnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam, OUT LRESULT *plrResult)
Definition: taskband.cpp:289
HRESULT STDMETHODCALLTYPE Initialize(IN OUT ITrayWindow *tray, HWND hWndStartButton)
Definition: taskband.cpp:326
virtual HRESULT STDMETHODCALLTYPE GetSite(IN REFIID riid, OUT VOID **ppvSite)
Definition: taskband.cpp:272
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1332
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define COM_INTERFACE_ENTRY2_IID(iid, x, x2)
Definition: atlcom.h:609
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:581
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:601
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:679
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:651
#define END_COM_MAP()
Definition: atlcom.h:592
const IID IID_IObjectWithSite
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
unsigned int UINT
Definition: ndis.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
const GUID IID_IOleWindow
const GUID IID_IPersist
Definition: proxy.cpp:14
const GUID IID_IPersistStream
Definition: proxy.cpp:13
#define TB_GETBUTTONSIZE
Definition: commctrl.h:1160
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define TRACE(s)
Definition: solgame.cpp:4
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
const GUID CLSID_ITaskBand
Definition: taskband.cpp:27
HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, HWND hWndStartButton, REFIID riid, void **ppv)
Definition: taskband.cpp:346
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define S_FALSE
Definition: winerror.h:2357
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI IsChild(_In_ HWND, _In_ HWND)
#define GW_CHILD
Definition: winuser.h:763
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IID_PPV_ARG(Itype, ppType)