[RSHELL]
[reactos.git] / base / shell / rshell / logging / CMenuBandWrap.cpp
1 /*
2 * Shell Menu Band
3 *
4 * Copyright 2014 David Quintana
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 St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20 #include "precomp.h"
21 #include "wraplog.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(CMenuBandWrap);
24
25 class CMenuBandWrap :
26 public CComCoClass<CMenuBandWrap>,
27 public CComObjectRootEx<CComMultiThreadModelNoCS>,
28 public IDeskBand,
29 public IObjectWithSite,
30 public IInputObject,
31 public IPersistStream,
32 public IOleCommandTarget,
33 public IServiceProvider,
34 public IMenuPopup,
35 public IMenuBand,
36 public IShellMenu2,
37 public IWinEventHandler,
38 public IShellMenuAcc
39 {
40 public:
41 CMenuBandWrap() {}
42 ~CMenuBandWrap();
43
44 HRESULT InitWrap(IShellMenu * shellMenu);
45
46 private:
47 CComPtr<IDeskBand > m_IDeskBand;
48 CComPtr<IDockingWindow > m_IDockingWindow;
49 CComPtr<IOleWindow > m_IOleWindow;
50 CComPtr<IObjectWithSite > m_IObjectWithSite;
51 CComPtr<IInputObject > m_IInputObject;
52 CComPtr<IPersistStream > m_IPersistStream;
53 CComPtr<IPersist > m_IPersist;
54 CComPtr<IOleCommandTarget > m_IOleCommandTarget;
55 CComPtr<IServiceProvider > m_IServiceProvider;
56 CComPtr<IMenuPopup > m_IMenuPopup;
57 CComPtr<IDeskBar > m_IDeskBar;
58 CComPtr<IMenuBand > m_IMenuBand;
59 CComPtr<IShellMenu2 > m_IShellMenu2;
60 CComPtr<IShellMenu > m_IShellMenu;
61 CComPtr<IWinEventHandler > m_IWinEventHandler;
62 CComPtr<IShellMenuAcc > m_IShellMenuAcc;
63
64 IUnknown * m_site;
65
66 public:
67
68 // *** IDeskBand methods ***
69 virtual HRESULT STDMETHODCALLTYPE GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi);
70
71 // *** IDockingWindow methods ***
72 virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow);
73 virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved);
74 virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved);
75
76 // *** IOleWindow methods ***
77 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
78 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
79
80 // *** IObjectWithSite methods ***
81 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
82 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite);
83
84 // *** IInputObject methods ***
85 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
86 virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
87 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
88
89 // *** IPersistStream methods ***
90 virtual HRESULT STDMETHODCALLTYPE IsDirty();
91 virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
92 virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
93 virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
94
95 // *** IPersist methods ***
96 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
97
98 // *** IOleCommandTarget methods ***
99 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText);
100 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
101
102 // *** IServiceProvider methods ***
103 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
104
105 // *** IMenuPopup methods ***
106 virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags);
107 virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType);
108 virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet);
109
110 // *** IDeskBar methods ***
111 virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient);
112 virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
113 virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(RECT *prc);
114
115 // *** IMenuBand methods ***
116 virtual HRESULT STDMETHODCALLTYPE IsMenuMessage(MSG *pmsg);
117 virtual HRESULT STDMETHODCALLTYPE TranslateMenuMessage(MSG *pmsg, LRESULT *plRet);
118
119 // *** IShellMenu methods ***
120 virtual HRESULT STDMETHODCALLTYPE Initialize(IShellMenuCallback *psmc, UINT uId, UINT uIdAncestor, DWORD dwFlags);
121 virtual HRESULT STDMETHODCALLTYPE GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags);
122 virtual HRESULT STDMETHODCALLTYPE SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
123 virtual HRESULT STDMETHODCALLTYPE GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
124 virtual HRESULT STDMETHODCALLTYPE SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
125 virtual HRESULT STDMETHODCALLTYPE GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
126 virtual HRESULT STDMETHODCALLTYPE InvalidateItem(LPSMDATA psmd, DWORD dwFlags);
127 virtual HRESULT STDMETHODCALLTYPE GetState(LPSMDATA psmd);
128 virtual HRESULT STDMETHODCALLTYPE SetMenuToolbar(IUnknown *punk, DWORD dwFlags);
129
130 // *** IWinEventHandler methods ***
131 virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
132 virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
133
134 // *** IShellMenu2 methods ***
135 virtual HRESULT STDMETHODCALLTYPE GetSubMenu(THIS);
136 virtual HRESULT STDMETHODCALLTYPE SetToolbar(THIS);
137 virtual HRESULT STDMETHODCALLTYPE SetMinWidth(THIS);
138 virtual HRESULT STDMETHODCALLTYPE SetNoBorder(THIS);
139 virtual HRESULT STDMETHODCALLTYPE SetTheme(THIS);
140
141 // *** IShellMenuAcc methods ***
142 virtual HRESULT STDMETHODCALLTYPE GetTop(THIS);
143 virtual HRESULT STDMETHODCALLTYPE GetBottom(THIS);
144 virtual HRESULT STDMETHODCALLTYPE GetTracked(THIS);
145 virtual HRESULT STDMETHODCALLTYPE GetParentSite(THIS);
146 virtual HRESULT STDMETHODCALLTYPE GetState(THIS);
147 virtual HRESULT STDMETHODCALLTYPE DoDefaultAction(THIS);
148 virtual HRESULT STDMETHODCALLTYPE IsEmpty(THIS);
149
150 DECLARE_NOT_AGGREGATABLE(CMenuBandWrap)
151 DECLARE_PROTECT_FINAL_CONSTRUCT()
152
153 BEGIN_COM_MAP(CMenuBandWrap)
154 COM_INTERFACE_ENTRY_IID(IID_IDeskBar, IMenuPopup)
155 COM_INTERFACE_ENTRY_IID(IID_IShellMenu, IShellMenu)
156 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
157 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IDeskBand)
158 COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
159 COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
160 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
161 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
162 COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
163 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersistStream)
164 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
165 COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
166 COM_INTERFACE_ENTRY_IID(IID_IMenuBand, IMenuBand)
167 COM_INTERFACE_ENTRY_IID(IID_IShellMenu2, IShellMenu2)
168 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
169 COM_INTERFACE_ENTRY_IID(IID_IShellMenuAcc, IShellMenuAcc)
170 END_COM_MAP()
171 };
172
173 extern "C"
174 HRESULT CMenuBand_Wrapper(IShellMenu * shellMenu, REFIID riid, LPVOID *ppv)
175 {
176 HRESULT hr;
177
178 *ppv = NULL;
179
180 CMenuBandWrap * site = new CComObject<CMenuBandWrap>();
181
182 if (!site)
183 return E_OUTOFMEMORY;
184
185 hr = site->InitWrap(shellMenu);
186 if (FAILED(hr))
187 {
188 site->Release();
189 return hr;
190 }
191
192 hr = site->QueryInterface(riid, ppv);
193
194 if (FAILED(hr))
195 site->Release();
196
197 return hr;
198 }
199
200 HRESULT CMenuBandWrap::InitWrap(IShellMenu * shellMenu)
201 {
202 HRESULT hr;
203
204 WrapLogOpen();
205
206 m_IShellMenu = shellMenu;
207
208 hr = shellMenu->QueryInterface(IID_PPV_ARG(IDeskBand, &m_IDeskBand));
209 if (FAILED(hr)) return hr;
210 hr = shellMenu->QueryInterface(IID_PPV_ARG(IDockingWindow, &m_IDockingWindow));
211 if (FAILED(hr)) return hr;
212 hr = shellMenu->QueryInterface(IID_PPV_ARG(IOleWindow, &m_IOleWindow));
213 if (FAILED(hr)) return hr;
214 hr = shellMenu->QueryInterface(IID_PPV_ARG(IObjectWithSite, &m_IObjectWithSite));
215 if (FAILED(hr)) return hr;
216 hr = shellMenu->QueryInterface(IID_PPV_ARG(IInputObject, &m_IInputObject));
217 if (FAILED(hr)) return hr;
218 hr = shellMenu->QueryInterface(IID_PPV_ARG(IPersistStream, &m_IPersistStream));
219 if (FAILED(hr)) return hr;
220 hr = shellMenu->QueryInterface(IID_PPV_ARG(IPersist, &m_IPersist));
221 if (FAILED(hr)) return hr;
222 hr = shellMenu->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &m_IOleCommandTarget));
223 if (FAILED(hr)) return hr;
224 hr = shellMenu->QueryInterface(IID_PPV_ARG(IServiceProvider, &m_IServiceProvider));
225 if (FAILED(hr)) return hr;
226 hr = shellMenu->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_IMenuPopup));
227 if (FAILED(hr)) return hr;
228 hr = shellMenu->QueryInterface(IID_PPV_ARG(IDeskBar, &m_IDeskBar));
229 if (FAILED(hr)) return hr;
230 hr = shellMenu->QueryInterface(IID_PPV_ARG(IMenuBand, &m_IMenuBand));
231 if (FAILED(hr)) return hr;
232 hr = shellMenu->QueryInterface(IID_PPV_ARG(IShellMenu2, &m_IShellMenu2));
233 if (FAILED(hr)) return hr;
234 hr = shellMenu->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_IWinEventHandler));
235 if (FAILED(hr)) return hr;
236 //hr = shellMenu->QueryInterface(IID_PPV_ARG(IShellMenuAcc, &m_IShellMenuAcc));
237 m_IShellMenuAcc = NULL;
238 return hr;
239 }
240
241 CMenuBandWrap::~CMenuBandWrap()
242 {
243 WrapLogClose();
244 }
245
246
247 // *** IShellMenu2 methods ***
248 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetSubMenu(THIS)
249 {
250 WrapLogEnter("CMenuBandWrap<%p>::GetSubMenu()\n", this);
251 HRESULT hr = m_IShellMenu2->GetSubMenu();
252 WrapLogExit("CMenuBandWrap::GetSubMenu()", hr);
253 return hr;
254 }
255
256 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetToolbar(THIS)
257 {
258 WrapLogEnter("CMenuBandWrap<%p>::SetToolbar()\n", this);
259 HRESULT hr = m_IShellMenu2->SetToolbar();
260 WrapLogExit("CMenuBandWrap::SetToolbar()", hr);
261 return hr;
262 }
263
264 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetMinWidth(THIS)
265 {
266 WrapLogEnter("CMenuBandWrap<%p>::SetMinWidth()\n", this);
267 HRESULT hr = m_IShellMenu2->SetMinWidth();
268 WrapLogExit("CMenuBandWrap::SetMinWidth()", hr);
269 return hr;
270 }
271
272 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetNoBorder(THIS)
273 {
274 WrapLogEnter("CMenuBandWrap<%p>::SetNoBorder()\n", this);
275 HRESULT hr = m_IShellMenu2->SetNoBorder();
276 WrapLogExit("CMenuBandWrap::SetNoBorder()", hr);
277 return hr;
278 }
279
280 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetTheme(THIS)
281 {
282 WrapLogEnter("CMenuBandWrap<%p>::SetTheme()\n", this);
283 HRESULT hr = m_IShellMenu2->SetTheme();
284 WrapLogExit("CMenuBandWrap::SetTheme()", hr);
285 return hr;
286 }
287
288
289 // *** IShellMenuAcc methods ***
290 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetTop(THIS)
291 {
292 WrapLogEnter("CMenuBandWrap<%p>::GetTop()\n", this);
293 HRESULT hr = m_IShellMenuAcc->GetTop();
294 WrapLogExit("CMenuBandWrap::GetTop()", hr);
295 return hr;
296 }
297
298 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetBottom(THIS)
299 {
300 WrapLogEnter("CMenuBandWrap<%p>::GetBottom()\n", this);
301 HRESULT hr = m_IShellMenuAcc->GetBottom();
302 WrapLogExit("CMenuBandWrap::GetBottom()", hr);
303 return hr;
304 }
305
306 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetTracked(THIS)
307 {
308 WrapLogEnter("CMenuBandWrap<%p>::GetBottom()\n", this);
309 HRESULT hr = m_IShellMenuAcc->GetBottom();
310 WrapLogExit("CMenuBandWrap::GetBottom()", hr);
311 return hr;
312 }
313
314 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetParentSite(THIS)
315 {
316 WrapLogEnter("CMenuBandWrap<%p>::GetBottom()\n", this);
317 HRESULT hr = m_IShellMenuAcc->GetBottom();
318 WrapLogExit("CMenuBandWrap::GetBottom()", hr);
319 return hr;
320 }
321
322 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetState(THIS)
323 {
324 WrapLogEnter("CMenuBandWrap<%p>::GetBottom()\n", this);
325 HRESULT hr = m_IShellMenuAcc->GetBottom();
326 WrapLogExit("CMenuBandWrap::GetBottom()", hr);
327 return hr;
328 }
329
330 HRESULT STDMETHODCALLTYPE CMenuBandWrap::DoDefaultAction(THIS)
331 {
332 WrapLogEnter("CMenuBandWrap<%p>::GetBottom()\n", this);
333 HRESULT hr = m_IShellMenuAcc->GetBottom();
334 WrapLogExit("CMenuBandWrap::GetBottom()", hr);
335 return hr;
336 }
337
338 HRESULT STDMETHODCALLTYPE CMenuBandWrap::IsEmpty(THIS)
339 {
340 WrapLogEnter("CMenuBandWrap<%p>::GetBottom()\n", this);
341 HRESULT hr = m_IShellMenuAcc->GetBottom();
342 WrapLogExit("CMenuBandWrap::GetBottom()", hr);
343 return hr;
344 }
345
346 // *** IDeskBand methods ***
347 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi)
348 {
349 WrapLogEnter("CMenuBandWrap<%p>::GetBandInfo(DWORD dwBandID=%d, DWORD dwViewMode=%d, DESKBANDINFO *pdbi=%p)\n", this, dwBandID, dwViewMode, pdbi);
350 HRESULT hr = m_IDeskBand->GetBandInfo(dwBandID, dwViewMode, pdbi);
351 WrapLogExit("CMenuBandWrap::GetBandInfo()", hr);
352 return hr;
353 }
354
355 // *** IDockingWindow methods ***
356 HRESULT STDMETHODCALLTYPE CMenuBandWrap::ShowDW(BOOL fShow)
357 {
358 WrapLogEnter("CMenuBandWrap<%p>::ShowDW(BOOL fShow=%d)\n", this, fShow);
359 HRESULT hr = m_IDockingWindow->ShowDW(fShow);
360 WrapLogExit("CMenuBandWrap::ShowDW()", hr);
361 return hr;
362 }
363
364 HRESULT STDMETHODCALLTYPE CMenuBandWrap::CloseDW(DWORD dwReserved)
365 {
366 WrapLogEnter("CMenuBandWrap<%p>::CloseDW(DWORD dwReserved=%d)\n", this, dwReserved);
367 HRESULT hr = m_IDockingWindow->CloseDW(dwReserved);
368 WrapLogExit("CMenuBandWrap::CloseDW()", hr);
369 return hr;
370 }
371
372 HRESULT STDMETHODCALLTYPE CMenuBandWrap::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
373 {
374 WrapLogEnter("CMenuBandWrap<%p>::ResizeBorderDW(LPCRECT prcBorder=%p, IUnknown *punkToolbarSite=%p, BOOL fReserved=%d)\n", this, prcBorder, punkToolbarSite, fReserved);
375 if (prcBorder) WrapLogPre("*prcBorder=%s\n", Wrap(*prcBorder));
376 HRESULT hr = m_IDockingWindow->ResizeBorderDW(prcBorder, punkToolbarSite, fReserved);
377 if (prcBorder) WrapLogPost("*prcBorder=%s\n", Wrap(*prcBorder));
378 WrapLogExit("CMenuBandWrap::ResizeBorderDW()", hr);
379 return hr;
380 }
381
382 // *** IOleWindow methods ***
383 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetWindow(HWND *phwnd)
384 {
385 WrapLogEnter("CMenuBandWrap<%p>::GetWindow(HWND *phwnd=%p)\n", this, phwnd);
386 HRESULT hr = m_IOleWindow->GetWindow(phwnd);
387 if (phwnd) WrapLogPost("*phwnd=%p\n", *phwnd);
388 WrapLogExit("CMenuBandWrap::GetWindow()", hr);
389 return hr;
390 }
391 HRESULT STDMETHODCALLTYPE CMenuBandWrap::ContextSensitiveHelp(BOOL fEnterMode)
392 {
393 WrapLogEnter("CMenuBandWrap<%p>::ContextSensitiveHelp(BOOL fEnterMode=%d)\n", this, fEnterMode);
394 HRESULT hr = m_IOleWindow->ContextSensitiveHelp(fEnterMode);
395 WrapLogExit("CMenuBandWrap::ContextSensitiveHelp()", hr);
396 return hr;
397 }
398
399 // *** IWinEventHandler methods ***
400 HRESULT STDMETHODCALLTYPE CMenuBandWrap::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
401 {
402 //WrapLogEnter("CMenuBandWrap<%p>::OnWinEvent(HWND hWnd=%p, UINT uMsg=%u, WPARAM wParam=%08x, LPARAM lParam=%08x, LRESULT *theResult=%p)\n", this, hWnd, uMsg, wParam, lParam, theResult);
403 HRESULT hr = m_IWinEventHandler->OnWinEvent(hWnd, uMsg, wParam, lParam, theResult);
404 //WrapLogExit("CMenuBandWrap::OnWinEvent()", hr);
405 return hr;
406 }
407
408 HRESULT STDMETHODCALLTYPE CMenuBandWrap::IsWindowOwner(HWND hWnd)
409 {
410 //WrapLogEnter("CMenuBandWrap<%p>::IsWindowOwner(HWND hWnd=%08x)\n", this, hWnd);
411 HRESULT hr = m_IWinEventHandler->IsWindowOwner(hWnd);
412 //WrapLogExit("CMenuBandWrap::IsWindowOwner()", hr);
413 return hr;
414 }
415
416 // *** IObjectWithSite methods ***
417 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetSite(IUnknown *pUnkSite)
418 {
419 WrapLogEnter("CMenuBandWrap<%p>::SetSite(IUnknown *pUnkSite=%p)\n", this, pUnkSite);
420 HRESULT hr = m_IObjectWithSite->SetSite(pUnkSite);
421 WrapLogExit("CMenuBandWrap::SetSite()", hr);
422 m_site = pUnkSite;
423 return hr;
424 }
425
426 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetSite(REFIID riid, PVOID *ppvSite)
427 {
428 WrapLogEnter("CMenuBandWrap<%p>::GetSite(REFIID riid=%s, PVOID *ppvSite=%p)\n", this, Wrap(riid), ppvSite);
429 HRESULT hr = m_IObjectWithSite->GetSite(riid, ppvSite);
430 if (ppvSite) WrapLogPost("*ppvSite=%p\n", *ppvSite);
431 WrapLogExit("CMenuBandWrap::GetSite()", hr);
432 return hr;
433 }
434
435 // *** IInputObject methods ***
436 HRESULT STDMETHODCALLTYPE CMenuBandWrap::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
437 {
438 WrapLogEnter("CMenuBandWrap<%p>::UIActivateIO(BOOL fActivate=%d, LPMSG lpMsg=%p)\n", this, fActivate, lpMsg);
439 HRESULT hr = m_IInputObject->UIActivateIO(fActivate, lpMsg);
440 WrapLogExit("CMenuBandWrap::UIActivateIO()", hr);
441
442 HRESULT hrt;
443 CComPtr<IMenuPopup> pmp;
444
445 hrt = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup, &pmp));
446 if (FAILED(hrt))
447 return hr;
448
449 hrt = pmp->SetSubMenu(this, fActivate);
450
451 return hr;
452 }
453
454 HRESULT STDMETHODCALLTYPE CMenuBandWrap::HasFocusIO()
455 {
456 WrapLogEnter("CMenuBandWrap<%p>::HasFocusIO()\n", this);
457 HRESULT hr = m_IInputObject->HasFocusIO();
458 WrapLogExit("CMenuBandWrap::HasFocusIO()", hr);
459 return hr;
460 }
461
462 HRESULT STDMETHODCALLTYPE CMenuBandWrap::TranslateAcceleratorIO(LPMSG lpMsg)
463 {
464 WrapLogEnter("CMenuBandWrap<%p>::TranslateAcceleratorIO(LPMSG lpMsg=%p)\n", this, lpMsg);
465 if (lpMsg) WrapLogPre("*lpMsg=%s\n", Wrap(*lpMsg));
466 HRESULT hr = m_IInputObject->TranslateAcceleratorIO(lpMsg);
467 WrapLogExit("CMenuBandWrap::TranslateAcceleratorIO()", hr);
468 return hr;
469 }
470
471 // *** IPersistStream methods ***
472 HRESULT STDMETHODCALLTYPE CMenuBandWrap::IsDirty()
473 {
474 WrapLogEnter("CMenuBandWrap<%p>::IsDirty()\n", this);
475 HRESULT hr = m_IPersistStream->IsDirty();
476 WrapLogExit("CMenuBandWrap::IsDirty()", hr);
477 return hr;
478 }
479 HRESULT STDMETHODCALLTYPE CMenuBandWrap::Load(IStream *pStm)
480 {
481 WrapLogEnter("CMenuBandWrap<%p>::Load(IStream *pStm=%p)\n", this, pStm);
482 HRESULT hr = m_IPersistStream->Load(pStm);
483 WrapLogExit("CMenuBandWrap::Load()", hr);
484 return hr;
485 }
486 HRESULT STDMETHODCALLTYPE CMenuBandWrap::Save(IStream *pStm, BOOL fClearDirty)
487 {
488 WrapLogEnter("CMenuBandWrap<%p>::Save(IStream *pStm=%p, BOOL fClearDirty=%d)\n", this, pStm, fClearDirty);
489 HRESULT hr = m_IPersistStream->Save(pStm, fClearDirty);
490 WrapLogExit("CMenuBandWrap::Save()", hr);
491 return hr;
492 }
493 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetSizeMax(ULARGE_INTEGER *pcbSize)
494 {
495 WrapLogEnter("CMenuBandWrap<%p>::GetSizeMax(ULARGE_INTEGER *pcbSize=%p)\n", this, pcbSize);
496 HRESULT hr = m_IPersistStream->GetSizeMax(pcbSize);
497 WrapLogExit("CMenuBandWrap::GetSizeMax()", hr);
498 return hr;
499 }
500
501 // *** IPersist methods ***
502 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetClassID(CLSID *pClassID)
503 {
504 WrapLogEnter("CMenuBandWrap<%p>::GetClassID(CLSID *pClassID=%p)\n", this, pClassID);
505 HRESULT hr = m_IPersist->GetClassID(pClassID);
506 if (pClassID) WrapLogPost("*pClassID=%s\n", Wrap(*pClassID));
507 WrapLogExit("CMenuBandWrap::GetClassID()", hr);
508 return hr;
509 }
510
511 // *** IOleCommandTarget methods ***
512 HRESULT STDMETHODCALLTYPE CMenuBandWrap::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
513 {
514 WrapLogEnter("CMenuBandWrap<%p>::QueryStatus(const GUID *pguidCmdGroup=%p, ULONG cCmds=%u, prgCmds=%p, pCmdText=%p)\n", this, pguidCmdGroup, cCmds, prgCmds, pCmdText);
515 HRESULT hr = m_IOleCommandTarget->QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText);
516 if (pguidCmdGroup) WrapLogPost("*pguidCmdGroup=%s\n", Wrap(*pguidCmdGroup));
517 WrapLogExit("CMenuBandWrap::QueryStatus()", hr);
518 return hr;
519 }
520
521 HRESULT STDMETHODCALLTYPE CMenuBandWrap::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
522 {
523 WrapLogEnter("CMenuBandWrap<%p>::Exec(const GUID *pguidCmdGroup=%p, DWORD nCmdID=%d, DWORD nCmdexecopt=%d, VARIANT *pvaIn=%p, VARIANT *pvaOut=%p)\n", this, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
524 if (pguidCmdGroup) WrapLogPre("*pguidCmdGroup=%s\n", Wrap(*pguidCmdGroup));
525 HRESULT hr = m_IOleCommandTarget->Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
526 WrapLogExit("CMenuBandWrap::Exec()", hr);
527 return hr;
528 }
529
530 // *** IServiceProvider methods ***
531 HRESULT STDMETHODCALLTYPE CMenuBandWrap::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
532 {
533 WrapLogEnter("CMenuBandWrap<%p>::QueryService(REFGUID guidService=%s, REFIID riid=%s, void **ppvObject=%p)\n", this, Wrap(guidService), Wrap(riid), ppvObject);
534
535 if (IsEqualIID(guidService, SID_SMenuBandChild))
536 {
537 WrapLogPre("SID is SID_SMenuBandChild. Using QueryInterface of self instead of wrapped object.\n");
538 HRESULT hr = this->QueryInterface(riid, ppvObject);
539 if (SUCCEEDED(hr))
540 {
541 if (ppvObject) WrapLogPost("*ppvObject=%p\n", *ppvObject);
542 WrapLogExit("CMenuBandWrap::QueryService()", hr);
543 return hr;
544 }
545 else
546 {
547 WrapLogPre("QueryInterface on wrapper failed. Handing over to innter object.\n");
548 }
549 }
550 else if (IsEqualIID(guidService, SID_SMenuBandBottom))
551 {
552 WrapLogPre("SID is SID_SMenuBandBottom. Using QueryInterface of self instead of wrapped object.\n");
553 HRESULT hr = this->QueryInterface(riid, ppvObject);
554 if (SUCCEEDED(hr))
555 {
556 if (ppvObject) WrapLogPost("*ppvObject=%p\n", *ppvObject);
557 WrapLogExit("CMenuBandWrap::QueryService()", hr);
558 return hr;
559 }
560 else
561 {
562 WrapLogPre("QueryInterface on wrapper failed. Handing over to innter object.\n");
563 }
564 }
565 else if (IsEqualIID(guidService, SID_SMenuBandBottomSelected))
566 {
567 WrapLogPre("SID is SID_SMenuBandBottomSelected. Using QueryInterface of self instead of wrapped object.\n");
568 HRESULT hr = this->QueryInterface(riid, ppvObject);
569 if (SUCCEEDED(hr))
570 {
571 if (ppvObject) WrapLogPost("*ppvObject=%p\n", *ppvObject);
572 WrapLogExit("CMenuBandWrap::QueryService()", hr);
573 return hr;
574 }
575 else
576 {
577 WrapLogPre("QueryInterface on wrapper failed. Handing over to innter object.\n");
578 }
579 }
580 else
581 {
582 WrapLogPre("SID not identified.\n");
583 }
584 HRESULT hr = m_IServiceProvider->QueryService(guidService, riid, ppvObject);
585 if (ppvObject) WrapLogPost("*ppvObject=%p\n", *ppvObject);
586 WrapLogExit("CMenuBandWrap::QueryService()", hr);
587 return hr;
588 }
589
590
591 // *** IMenuPopup methods ***
592 HRESULT STDMETHODCALLTYPE CMenuBandWrap::Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags)
593 {
594 WrapLogEnter("CMenuBandWrap<%p>::Popup(POINTL *ppt=%p, RECTL *prcExclude=%p, MP_POPUPFLAGS dwFlags=%08x)\n", this, ppt, prcExclude, dwFlags);
595 HRESULT hr = m_IMenuPopup->Popup(ppt, prcExclude, dwFlags);
596 WrapLogExit("CMenuBandWrap::Popup()", hr);
597 return hr;
598 }
599
600 HRESULT STDMETHODCALLTYPE CMenuBandWrap::OnSelect(DWORD dwSelectType)
601 {
602 WrapLogEnter("CMenuBandWrap<%p>::OnSelect(DWORD dwSelectType=%08x)\n", this, dwSelectType);
603 HRESULT hr = m_IMenuPopup->OnSelect(dwSelectType);
604 WrapLogExit("CMenuBandWrap::OnSelect()", hr);
605 return hr;
606 }
607
608 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
609 {
610 WrapLogEnter("CMenuBandWrap<%p>::SetSubMenu(IMenuPopup *pmp=%p, BOOL fSet=%d)\n", this, pmp, fSet);
611 HRESULT hr = m_IMenuPopup->SetSubMenu(pmp, fSet);
612 WrapLogExit("CMenuBandWrap::SetSubMenu()", hr);
613 return hr;
614 }
615
616
617 // *** IDeskBar methods ***
618 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetClient(IUnknown *punkClient)
619 {
620 WrapLogEnter("CMenuBandWrap<%p>::SetClient(IUnknown *punkClient=%p)\n", this, punkClient);
621 HRESULT hr = m_IDeskBar->SetClient(punkClient);
622 WrapLogExit("CMenuBandWrap::SetClient()", hr);
623 return hr;
624 }
625
626 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetClient(IUnknown **ppunkClient)
627 {
628 WrapLogEnter("CMenuBandWrap<%p>::GetClient(IUnknown **ppunkClient=%p)\n", this, ppunkClient);
629 HRESULT hr = m_IDeskBar->GetClient(ppunkClient);
630 if (ppunkClient) WrapLogPost("*ppunkClient=%p\n", *ppunkClient);
631 WrapLogExit("CMenuBandWrap::GetClient()", hr);
632 return hr;
633 }
634
635 HRESULT STDMETHODCALLTYPE CMenuBandWrap::OnPosRectChangeDB(RECT *prc)
636 {
637 WrapLogEnter("CMenuBandWrap<%p>::OnPosRectChangeDB(RECT *prc=%p)\n", this, prc);
638 HRESULT hr = m_IDeskBar->OnPosRectChangeDB(prc);
639 if (prc) WrapLogPost("*prc=%s\n", Wrap(*prc));
640 WrapLogExit("CMenuBandWrap::OnPosRectChangeDB()", hr);
641 return hr;
642 }
643
644
645 // *** IMenuBand methods ***
646 HRESULT STDMETHODCALLTYPE CMenuBandWrap::IsMenuMessage(MSG *pmsg)
647 {
648 //WrapLogEnter("CMenuBandWrap<%p>::IsMenuMessage(MSG *pmsg=%p)\n", this, pmsg);
649 HRESULT hr = m_IMenuBand->IsMenuMessage(pmsg);
650 //WrapLogExit("CMenuBandWrap::IsMenuMessage()", hr);
651 return hr;
652 }
653
654 HRESULT STDMETHODCALLTYPE CMenuBandWrap::TranslateMenuMessage(MSG *pmsg, LRESULT *plRet)
655 {
656 //WrapLogEnter("CMenuBandWrap<%p>::TranslateMenuMessage(MSG *pmsg=%p, LRESULT *plRet=%p)\n", this, pmsg, plRet);
657 HRESULT hr = m_IMenuBand->TranslateMenuMessage(pmsg, plRet);
658 //WrapLogExit("CMenuBandWrap::TranslateMenuMessage(*plRet=%d) = %08x\n", *plRet, hr);
659 return hr;
660 }
661
662 // *** IShellMenu methods ***
663 HRESULT STDMETHODCALLTYPE CMenuBandWrap::Initialize(IShellMenuCallback *psmc, UINT uId, UINT uIdAncestor, DWORD dwFlags)
664 {
665 WrapLogEnter("CMenuBandWrap<%p>::Initialize(IShellMenuCallback *psmc=%p, UINT uId=%u, UINT uIdAncestor=%u, DWORD dwFlags=%08x)\n", this, psmc, uId, uIdAncestor, dwFlags);
666 HRESULT hr = m_IShellMenu->Initialize(psmc, uId, uIdAncestor, dwFlags);
667 WrapLogExit("CMenuBandWrap::Initialize()", hr);
668 return hr;
669 }
670
671 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags)
672 {
673 WrapLogEnter("CMenuBandWrap<%p>::GetMenuInfo(IShellMenuCallback **ppsmc=%p, UINT *puId=%p, UINT *puIdAncestor=%p, DWORD *pdwFlags=%p)\n", this, ppsmc, puId, puIdAncestor, pdwFlags);
674 HRESULT hr = m_IShellMenu->GetMenuInfo(ppsmc, puId, puIdAncestor, pdwFlags);
675 if (ppsmc) WrapLogPost("*ppsmc=%p\n", *ppsmc);
676 if (puId) WrapLogPost("*puId=%u\n", *puId);
677 if (puIdAncestor) WrapLogPost("*puIdAncestor=%u\n", *puIdAncestor);
678 if (pdwFlags) WrapLogPost("*pdwFlags=%08x\n", *pdwFlags);
679 WrapLogExit("CMenuBandWrap::GetMenuInfo()", hr);
680 return hr;
681 }
682
683 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
684 {
685 WrapLogEnter("CMenuBandWrap<%p>::SetShellFolder(IShellFolder *psf=%p, LPCITEMIDLIST pidlFolder=%p, HKEY hKey=%p, DWORD dwFlags=%08x)\n", this, psf, pidlFolder, hKey, dwFlags);
686 HRESULT hr = m_IShellMenu->SetShellFolder(psf, pidlFolder, hKey, dwFlags);
687 WrapLogExit("CMenuBandWrap::SetShellFolder()", hr);
688 return hr;
689 }
690
691 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
692 {
693 WrapLogEnter("CMenuBandWrap<%p>::GetShellFolder(DWORD *pdwFlags=%p, LPITEMIDLIST *ppidl=%p, REFIID riid=%s, void **ppv=%p)\n", this, pdwFlags, ppidl, Wrap(riid), ppv);
694 HRESULT hr = m_IShellMenu->GetShellFolder(pdwFlags, ppidl, riid, ppv);
695 if (pdwFlags) WrapLogPost("*pdwFlags=%08x\n", *pdwFlags);
696 if (ppidl) WrapLogPost("*ppidl=%p\n", *ppidl);
697 if (ppv) WrapLogPost("*ppv=%p\n", *ppv);
698 WrapLogExit("CMenuBandWrap::GetShellFolder()", hr);
699 return hr;
700 }
701
702 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags)
703 {
704 WrapLogEnter("CMenuBandWrap<%p>::SetMenu(HMENU hmenu=%p, HWND hwnd=%p, DWORD dwFlags=%08x)\n", this, hmenu, hwnd, dwFlags);
705 HRESULT hr = m_IShellMenu->SetMenu(hmenu, hwnd, dwFlags);
706 WrapLogExit("CMenuBandWrap::SetMenu()", hr);
707 return hr;
708 }
709
710 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags)
711 {
712 WrapLogEnter("CMenuBandWrap<%p>::GetMenu(HMENU *phmenu=%p, HWND *phwnd=%p, DWORD *pdwFlags=%p)\n", this, phmenu, phwnd, pdwFlags);
713 HRESULT hr = m_IShellMenu->GetMenu(phmenu, phwnd, pdwFlags);
714 if (phmenu) WrapLogPost("*phmenu=%p\n", *phmenu);
715 if (phwnd) WrapLogPost("*phwnd=%p\n", *phwnd);
716 if (pdwFlags) WrapLogPost("*pdwFlags=%08x\n", *pdwFlags);
717 WrapLogExit("CMenuBandWrap::GetMenu()", hr);
718 return hr;
719 }
720
721 HRESULT STDMETHODCALLTYPE CMenuBandWrap::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
722 {
723 WrapLogEnter("CMenuBandWrap<%p>::InvalidateItem(LPSMDATA psmd=%p, DWORD dwFlags=%08x)\n", this, psmd, dwFlags);
724 HRESULT hr = m_IShellMenu->InvalidateItem(psmd, dwFlags);
725 WrapLogExit("CMenuBandWrap::InvalidateItem()", hr);
726 return hr;
727 }
728
729 HRESULT STDMETHODCALLTYPE CMenuBandWrap::GetState(LPSMDATA psmd)
730 {
731 WrapLogEnter("CMenuBandWrap<%p>::GetState(LPSMDATA psmd=%p)\n", this, psmd);
732 HRESULT hr = m_IShellMenu->GetState(psmd);
733 WrapLogExit("CMenuBandWrap::GetState()", hr);
734 return hr;
735 }
736
737 HRESULT STDMETHODCALLTYPE CMenuBandWrap::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
738 {
739 WrapLogEnter("CMenuBandWrap<%p>::SetMenuToolbar(IUnknown *punk=%p, DWORD dwFlags=%08x)\n", this, punk, dwFlags);
740 HRESULT hr = m_IShellMenu->SetMenuToolbar(punk, dwFlags);
741 WrapLogExit("CMenuBandWrap::SetMenuToolbar()", hr);
742 return hr;
743 }