[RSHELL]
[reactos.git] / base / shell / rshell / CMenuBand.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
22 WINE_DEFAULT_DEBUG_CHANNEL(CMenuBand);
23
24 #define WRAP_LOG 0
25
26 extern "C" BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
27
28 class CMenuBand;
29
30 class CMenuToolbarBase
31 {
32 public:
33 CMenuToolbarBase(CMenuBand *menuBand);
34 virtual ~CMenuToolbarBase() {}
35
36 HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
37 HRESULT GetWindow(HWND *phwnd);
38 HRESULT ShowWindow(BOOL fShow);
39 HRESULT Close();
40
41 virtual HRESULT FillToolbar() = 0;
42
43 protected:
44
45 static const UINT WM_USER_SHOWPOPUPMENU = WM_USER + 1;
46
47 CMenuBand *m_menuBand;
48 HWND m_hwnd;
49 DWORD m_dwMenuFlags;
50 };
51
52 class CMenuStaticToolbar : public CMenuToolbarBase
53 {
54 public:
55 CMenuStaticToolbar(CMenuBand *menuBand);
56 virtual ~CMenuStaticToolbar() {}
57
58 HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
59 HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
60
61 virtual HRESULT FillToolbar();
62
63 private:
64 HMENU m_hmenu;
65 };
66
67 class CMenuSFToolbar : public CMenuToolbarBase
68 {
69 public:
70 CMenuSFToolbar(CMenuBand *menuBand);
71 virtual ~CMenuSFToolbar();
72
73 HRESULT SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
74 HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
75
76 virtual HRESULT FillToolbar();
77
78 private:
79
80 IShellFolder * m_shellFolder;
81 LPCITEMIDLIST m_idList;
82 HKEY m_hKey;
83 };
84
85 class CMenuBand :
86 public CComCoClass<CMenuBand>,
87 public CComObjectRootEx<CComMultiThreadModelNoCS>,
88 public IDeskBand,
89 public IObjectWithSite,
90 public IInputObject,
91 public IPersistStream,
92 public IOleCommandTarget,
93 public IServiceProvider,
94 public IMenuPopup,
95 public IMenuBand,
96 public IShellMenu2,
97 public IWinEventHandler,
98 public IShellMenuAcc
99 {
100 public:
101 CMenuBand();
102 ~CMenuBand();
103
104 private:
105 #if WRAP_LOG
106 IUnknown * m_IUnknown;
107 IDeskBand * m_IDeskBand;
108 IDockingWindow * m_IDockingWindow;
109 IOleWindow * m_IOleWindow;
110 IObjectWithSite * m_IObjectWithSite;
111 IInputObject * m_IInputObject;
112 IPersistStream * m_IPersistStream;
113 IPersist * m_IPersist;
114 IOleCommandTarget * m_IOleCommandTarget;
115 IServiceProvider * m_IServiceProvider;
116 IMenuPopup * m_IMenuPopup;
117 IDeskBar * m_IDeskBar;
118 IMenuBand * m_IMenuBand;
119 IShellMenu2 * m_IShellMenu2;
120 IShellMenu * m_IShellMenu;
121 IWinEventHandler * m_IWinEventHandler;
122 IShellMenuAcc * m_IShellMenuAcc;
123 #else
124 IOleWindow *m_site;
125 IShellMenuCallback *m_psmc;
126
127 CMenuStaticToolbar *m_staticToolbar;
128 CMenuSFToolbar *m_SFToolbar;
129
130 UINT m_uId;
131 UINT m_uIdAncestor;
132 DWORD m_dwFlags;
133 PVOID m_UserData;
134 HMENU m_hmenu;
135 #endif
136
137 BOOL m_useBigIcons;
138
139 public:
140
141 // *** IDeskBand methods ***
142 virtual HRESULT STDMETHODCALLTYPE GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi);
143
144 // *** IDockingWindow methods ***
145 virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow);
146 virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved);
147 virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved);
148
149 // *** IOleWindow methods ***
150 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
151 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
152
153 // *** IObjectWithSite methods ***
154 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
155 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite);
156
157 // *** IInputObject methods ***
158 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
159 virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
160 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
161
162 // *** IPersistStream methods ***
163 virtual HRESULT STDMETHODCALLTYPE IsDirty();
164 virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
165 virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
166 virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
167
168 // *** IPersist methods ***
169 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
170
171 // *** IOleCommandTarget methods ***
172 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText);
173 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
174
175 // *** IServiceProvider methods ***
176 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
177
178 // *** IMenuPopup methods ***
179 virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags);
180 virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType);
181 virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet);
182
183 // *** IDeskBar methods ***
184 virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient);
185 virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
186 virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(RECT *prc);
187
188 // *** IMenuBand methods ***
189 virtual HRESULT STDMETHODCALLTYPE IsMenuMessage(MSG *pmsg);
190 virtual HRESULT STDMETHODCALLTYPE TranslateMenuMessage(MSG *pmsg, LRESULT *plRet);
191
192 // *** IShellMenu methods ***
193 virtual HRESULT STDMETHODCALLTYPE Initialize(IShellMenuCallback *psmc, UINT uId, UINT uIdAncestor, DWORD dwFlags);
194 virtual HRESULT STDMETHODCALLTYPE GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags);
195 virtual HRESULT STDMETHODCALLTYPE SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
196 virtual HRESULT STDMETHODCALLTYPE GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
197 virtual HRESULT STDMETHODCALLTYPE SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
198 virtual HRESULT STDMETHODCALLTYPE GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
199 virtual HRESULT STDMETHODCALLTYPE InvalidateItem(LPSMDATA psmd, DWORD dwFlags);
200 virtual HRESULT STDMETHODCALLTYPE GetState(LPSMDATA psmd);
201 virtual HRESULT STDMETHODCALLTYPE SetMenuToolbar(IUnknown *punk, DWORD dwFlags);
202
203 // *** IWinEventHandler methods ***
204 virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
205 virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
206
207 // *** IShellMenu2 methods ***
208 virtual HRESULT STDMETHODCALLTYPE GetSubMenu(THIS);
209 virtual HRESULT STDMETHODCALLTYPE SetToolbar(THIS);
210 virtual HRESULT STDMETHODCALLTYPE SetMinWidth(THIS);
211 virtual HRESULT STDMETHODCALLTYPE SetNoBorder(THIS);
212 virtual HRESULT STDMETHODCALLTYPE SetTheme(THIS);
213
214 // *** IShellMenuAcc methods ***
215 virtual HRESULT STDMETHODCALLTYPE GetTop(THIS);
216 virtual HRESULT STDMETHODCALLTYPE GetBottom(THIS);
217 virtual HRESULT STDMETHODCALLTYPE GetTracked(THIS);
218 virtual HRESULT STDMETHODCALLTYPE GetParentSite(THIS);
219 virtual HRESULT STDMETHODCALLTYPE GetState(THIS);
220 virtual HRESULT STDMETHODCALLTYPE DoDefaultAction(THIS);
221 virtual HRESULT STDMETHODCALLTYPE IsEmpty(THIS);
222
223 HRESULT CallCBWithId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam);
224
225 BOOL UseBigIcons() {
226 return m_useBigIcons;
227 }
228
229 DECLARE_NOT_AGGREGATABLE(CMenuBand)
230 DECLARE_PROTECT_FINAL_CONSTRUCT()
231
232 BEGIN_COM_MAP(CMenuBand)
233 COM_INTERFACE_ENTRY_IID(IID_IDeskBar, IMenuPopup)
234 COM_INTERFACE_ENTRY_IID(IID_IShellMenu, IShellMenu)
235 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
236 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IDeskBand)
237 COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
238 COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
239 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
240 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
241 COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
242 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersistStream)
243 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
244 COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
245 COM_INTERFACE_ENTRY_IID(IID_IMenuBand, IMenuBand)
246 COM_INTERFACE_ENTRY_IID(IID_IShellMenu2, IShellMenu2)
247 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
248 COM_INTERFACE_ENTRY_IID(IID_IShellMenuAcc, IShellMenuAcc)
249 END_COM_MAP()
250
251 private:
252 HRESULT _CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam);
253 };
254
255 extern "C"
256 HRESULT CMenuBand_Constructor(REFIID riid, LPVOID *ppv)
257 {
258 *ppv = NULL;
259
260 CMenuBand * site = new CComObject<CMenuBand>();
261
262 if (!site)
263 return E_OUTOFMEMORY;
264
265 HRESULT hr = site->QueryInterface(riid, ppv);
266
267 if (FAILED(hr))
268 site->Release();
269
270 return hr;
271 }
272
273
274 #if WRAP_LOG
275 #include <stdio.h>
276
277 static UINT openCount = 0;
278 static UINT callLevel;
279 static FILE*log;
280
281 static UINT nTemps;
282 static CHAR strTemp[10][256];
283
284 static void WrapLogOpen()
285 {
286 if (openCount == 0)
287 {
288 log = fopen("G:\\CMenuBand.log", "w");
289 nTemps = 0;
290 callLevel = 0;
291 }
292 openCount++;
293 }
294
295 static void WrapLogClose()
296 {
297 openCount--;
298 if (openCount == 0)
299 {
300 fclose(log);
301 log = NULL;
302 }
303 }
304
305 static void __cdecl WrapLogMsg(_Printf_format_string_ const char* msg, ...)
306 {
307 va_list args;
308 for (int i = 0; i < callLevel; i++)
309 fputs(" ", log);
310 fputs("-- ", log);
311 va_start(args, msg);
312 vfprintf(log, msg, args);
313 va_end(args);
314 fflush(log);
315 nTemps = 0;
316 }
317
318 static void __cdecl WrapLogEnter(_Printf_format_string_ const char* msg, ...)
319 {
320 va_list args;
321 for (int i = 0; i < callLevel; i++)
322 fputs(" ", log);
323 fputs("ENTER >> ", log);
324 va_start(args, msg);
325 vfprintf(log, msg, args);
326 va_end(args);
327 fflush(log);
328 callLevel++;
329 nTemps = 0;
330 }
331
332 static void __cdecl WrapLogExit(_Printf_format_string_ const char* msg, ...)
333 {
334 va_list args;
335 callLevel--;
336 for (int i = 0; i < callLevel; i++)
337 fputs(" ", log);
338 fputs("EXIT <<< ", log);
339 va_start(args, msg);
340 vfprintf(log, msg, args);
341 va_end(args);
342 fflush(log);
343 nTemps = 0;
344 }
345
346 template <class T>
347 static LPSTR Wrap(const T& value);
348
349 template <>
350 static LPSTR Wrap<GUID>(REFGUID guid)
351 {
352 LPSTR cGuid = strTemp[nTemps++];
353 sprintf(cGuid, "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
354 guid.Data1, guid.Data2, guid.Data3,
355 guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
356 guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
357 return cGuid;
358 }
359
360 template <>
361 static LPSTR Wrap<RECT>(const RECT& rect)
362 {
363 LPSTR cGuid = strTemp[nTemps++];
364 sprintf(cGuid, "{L: %d, T: %d, R: %d, B: %d}",
365 rect.left, rect.top, rect.right, rect.bottom);
366 return cGuid;
367 }
368
369 template <>
370 static LPSTR Wrap<OLECMD>(const OLECMD& cmd)
371 {
372 LPSTR cGuid = strTemp[nTemps++];
373 sprintf(cGuid, "{ID: %d, F: %d}",
374 cmd.cmdID, cmd.cmdf);
375 return cGuid;
376 }
377
378 template <>
379 static LPSTR Wrap<MSG>(const MSG& msg)
380 {
381 LPSTR cGuid = strTemp[nTemps++];
382 sprintf(cGuid, "{HWND: %d, Code: %d, W: %p, L: %p, T: %d, P.X: %d, P.Y: %d}",
383 msg.hwnd, msg.message, msg.wParam, msg.lParam, msg.time, msg.pt.x, msg.pt.y);
384 return cGuid;
385 }
386
387 CMenuBand::CMenuBand()
388 {
389 HRESULT hr;
390 WrapLogOpen();
391
392 hr = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellMenu, &m_IShellMenu));
393 hr = m_IShellMenu->QueryInterface(IID_PPV_ARG(IUnknown, &m_IUnknown));
394 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IDeskBand, &m_IDeskBand));
395 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IDockingWindow, &m_IDockingWindow));
396 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IOleWindow, &m_IOleWindow));
397 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IObjectWithSite, &m_IObjectWithSite));
398 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IInputObject, &m_IInputObject));
399 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IPersistStream, &m_IPersistStream));
400 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IPersist, &m_IPersist));
401 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &m_IOleCommandTarget));
402 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IServiceProvider, &m_IServiceProvider));
403 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_IMenuPopup));
404 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IDeskBar, &m_IDeskBar));
405 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IMenuBand, &m_IMenuBand));
406 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IShellMenu2, &m_IShellMenu2));
407 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_IWinEventHandler));
408 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IShellMenuAcc, &m_IShellMenuAcc));
409 }
410
411 CMenuBand::~CMenuBand()
412 {
413 m_IUnknown->Release();
414 m_IDeskBand->Release();
415 m_IDockingWindow->Release();
416 m_IOleWindow->Release();
417 m_IObjectWithSite->Release();
418 m_IInputObject->Release();
419 m_IPersistStream->Release();
420 m_IPersist->Release();
421 m_IOleCommandTarget->Release();
422 m_IServiceProvider->Release();
423 m_IMenuPopup->Release();
424 m_IDeskBar->Release();
425 m_IMenuBand->Release();
426 m_IShellMenu2->Release();
427 m_IShellMenu->Release();
428 m_IWinEventHandler->Release();
429 m_IShellMenuAcc->Release();
430 WrapLogClose();
431 }
432
433
434 // *** IShellMenu2 methods ***
435 HRESULT STDMETHODCALLTYPE CMenuBand::GetSubMenu(THIS)
436 {
437 WrapLogEnter("CMenuBand<%p>::GetSubMenu()\n", this);
438 HRESULT hr = m_IShellMenu2->GetSubMenu();
439 WrapLogExit("CMenuBand::GetSubMenu() = %08x\n", hr);
440 return hr;
441 }
442
443 HRESULT STDMETHODCALLTYPE CMenuBand::SetToolbar(THIS)
444 {
445 WrapLogEnter("CMenuBand<%p>::SetToolbar()\n", this);
446 HRESULT hr = m_IShellMenu2->SetToolbar();
447 WrapLogExit("CMenuBand::SetToolbar() = %08x\n", hr);
448 return hr;
449 }
450
451 HRESULT STDMETHODCALLTYPE CMenuBand::SetMinWidth(THIS)
452 {
453 WrapLogEnter("CMenuBand<%p>::SetMinWidth()\n", this);
454 HRESULT hr = m_IShellMenu2->SetMinWidth();
455 WrapLogExit("CMenuBand::SetMinWidth() = %08x\n", hr);
456 return hr;
457 }
458
459 HRESULT STDMETHODCALLTYPE CMenuBand::SetNoBorder(THIS)
460 {
461 WrapLogEnter("CMenuBand<%p>::SetNoBorder()\n", this);
462 HRESULT hr = m_IShellMenu2->SetNoBorder();
463 WrapLogExit("CMenuBand::SetNoBorder() = %08x\n", hr);
464 return hr;
465 }
466
467 HRESULT STDMETHODCALLTYPE CMenuBand::SetTheme(THIS)
468 {
469 WrapLogEnter("CMenuBand<%p>::SetTheme()\n", this);
470 HRESULT hr = m_IShellMenu2->SetTheme();
471 WrapLogExit("CMenuBand::SetTheme() = %08x\n", hr);
472 return hr;
473 }
474
475
476 // *** IShellMenuAcc methods ***
477 HRESULT STDMETHODCALLTYPE CMenuBand::GetTop(THIS)
478 {
479 WrapLogEnter("CMenuBand<%p>::GetTop()\n", this);
480 HRESULT hr = m_IShellMenuAcc->GetTop();
481 WrapLogExit("CMenuBand::GetTop() = %08x\n", hr);
482 return hr;
483 }
484
485 HRESULT STDMETHODCALLTYPE CMenuBand::GetBottom(THIS)
486 {
487 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
488 HRESULT hr = m_IShellMenuAcc->GetBottom();
489 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
490 return hr;
491 }
492
493 HRESULT STDMETHODCALLTYPE CMenuBand::GetTracked(THIS)
494 {
495 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
496 HRESULT hr = m_IShellMenuAcc->GetBottom();
497 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
498 return hr;
499 }
500
501 HRESULT STDMETHODCALLTYPE CMenuBand::GetParentSite(THIS)
502 {
503 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
504 HRESULT hr = m_IShellMenuAcc->GetBottom();
505 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
506 return hr;
507 }
508
509 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(THIS)
510 {
511 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
512 HRESULT hr = m_IShellMenuAcc->GetBottom();
513 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
514 return hr;
515 }
516
517 HRESULT STDMETHODCALLTYPE CMenuBand::DoDefaultAction(THIS)
518 {
519 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
520 HRESULT hr = m_IShellMenuAcc->GetBottom();
521 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
522 return hr;
523 }
524
525 HRESULT STDMETHODCALLTYPE CMenuBand::IsEmpty(THIS)
526 {
527 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
528 HRESULT hr = m_IShellMenuAcc->GetBottom();
529 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
530 return hr;
531 }
532
533 // *** IDeskBand methods ***
534 HRESULT STDMETHODCALLTYPE CMenuBand::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi)
535 {
536 WrapLogEnter("CMenuBand<%p>::GetBandInfo(DWORD dwBandID=%d, DWORD dwViewMode=%d, DESKBANDINFO *pdbi=%p)\n", this, dwBandID, dwViewMode, pdbi);
537 HRESULT hr = m_IDeskBand->GetBandInfo(dwBandID, dwViewMode, pdbi);
538 WrapLogExit("CMenuBand::GetBandInfo() = %08x\n", hr);
539 return hr;
540 }
541
542 // *** IDockingWindow methods ***
543 HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
544 {
545 WrapLogEnter("CMenuBand<%p>::ShowDW(BOOL fShow=%d)\n", this, fShow);
546 HRESULT hr = m_IDockingWindow->ShowDW(fShow);
547 WrapLogExit("CMenuBand::ShowDW() = %08x\n", hr);
548 return hr;
549 }
550
551 HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
552 {
553 WrapLogEnter("CMenuBand<%p>::CloseDW(DWORD dwReserved=%d)\n", this, dwReserved);
554 HRESULT hr = m_IDockingWindow->CloseDW(dwReserved);
555 WrapLogExit("CMenuBand::CloseDW() = %08x\n", hr);
556 return hr;
557 }
558
559 HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
560 {
561 WrapLogEnter("CMenuBand<%p>::ResizeBorderDW(LPCRECT prcBorder=%p, IUnknown *punkToolbarSite=%p, BOOL fReserved=%d)\n", this, prcBorder, punkToolbarSite, fReserved);
562 if (prcBorder) WrapLogMsg("*prcBorder=%s\n", Wrap(*prcBorder));
563 HRESULT hr = m_IDockingWindow->ResizeBorderDW(prcBorder, punkToolbarSite, fReserved);
564 if (prcBorder) WrapLogMsg("*prcBorder=%s\n", Wrap(*prcBorder));
565 WrapLogExit("CMenuBand::ResizeBorderDW() = %08x\n", hr);
566 return hr;
567 }
568
569 // *** IOleWindow methods ***
570 HRESULT STDMETHODCALLTYPE CMenuBand::GetWindow(HWND *phwnd)
571 {
572 WrapLogEnter("CMenuBand<%p>::GetWindow(HWND *phwnd=%p)\n", this, phwnd);
573 HRESULT hr = m_IOleWindow->GetWindow(phwnd);
574 if (phwnd) WrapLogMsg("*phwnd=%p\n", *phwnd);
575 WrapLogExit("CMenuBand::GetWindow() = %08x\n", hr);
576 return hr;
577 }
578 HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
579 {
580 WrapLogEnter("CMenuBand<%p>::ContextSensitiveHelp(BOOL fEnterMode=%d)\n", this, fEnterMode);
581 HRESULT hr = m_IOleWindow->ContextSensitiveHelp(fEnterMode);
582 WrapLogExit("CMenuBand::ContextSensitiveHelp() = %08x\n", hr);
583 return hr;
584 }
585
586 // *** IWinEventHandler methods ***
587 HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
588 {
589 //WrapLogEnter("CMenuBand<%p>::OnWinEvent(HWND hWnd=%p, UINT uMsg=%u, WPARAM wParam=%08x, LPARAM lParam=%08x, LRESULT *theResult=%p)\n", this, hWnd, uMsg, wParam, lParam, theResult);
590 HRESULT hr = m_IWinEventHandler->OnWinEvent(hWnd, uMsg, wParam, lParam, theResult);
591 //WrapLogExit("CMenuBand::OnWinEvent() = %08x\n", hr);
592 return hr;
593 }
594
595 HRESULT STDMETHODCALLTYPE CMenuBand::IsWindowOwner(HWND hWnd)
596 {
597 //WrapLogEnter("CMenuBand<%p>::IsWindowOwner(HWND hWnd=%08x)\n", this, hWnd);
598 HRESULT hr = m_IWinEventHandler->IsWindowOwner(hWnd);
599 //WrapLogExit("CMenuBand::IsWindowOwner() = %08x\n", hr);
600 return hr;
601 }
602
603 // *** IObjectWithSite methods ***
604 HRESULT STDMETHODCALLTYPE CMenuBand::SetSite(IUnknown *pUnkSite)
605 {
606 WrapLogEnter("CMenuBand<%p>::SetSite(IUnknown *pUnkSite=%p)\n", this, pUnkSite);
607 HRESULT hr = m_IObjectWithSite->SetSite(pUnkSite);
608 WrapLogExit("CMenuBand::SetSite() = %08x\n", hr);
609 return hr;
610 }
611
612 HRESULT STDMETHODCALLTYPE CMenuBand::GetSite(REFIID riid, PVOID *ppvSite)
613 {
614 WrapLogEnter("CMenuBand<%p>::GetSite(REFIID riid=%s, PVOID *ppvSite=%p)\n", this, Wrap(riid), ppvSite);
615 HRESULT hr = m_IObjectWithSite->GetSite(riid, ppvSite);
616 if (ppvSite) WrapLogMsg("*ppvSite=%p\n", *ppvSite);
617 WrapLogExit("CMenuBand::GetSite() = %08x\n", hr);
618 return hr;
619 }
620
621 // *** IInputObject methods ***
622 HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
623 {
624 WrapLogEnter("CMenuBand<%p>::UIActivateIO(BOOL fActivate=%d, LPMSG lpMsg=%p)\n", this, fActivate, lpMsg);
625 HRESULT hr = m_IInputObject->UIActivateIO(fActivate, lpMsg);
626 WrapLogExit("CMenuBand::UIActivateIO() = %08x\n", hr);
627 return hr;
628 }
629
630 HRESULT STDMETHODCALLTYPE CMenuBand::HasFocusIO()
631 {
632 WrapLogEnter("CMenuBand<%p>::HasFocusIO()\n", this);
633 HRESULT hr = m_IInputObject->HasFocusIO();
634 WrapLogExit("CMenuBand::HasFocusIO() = %08x\n", hr);
635 return hr;
636 }
637
638 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateAcceleratorIO(LPMSG lpMsg)
639 {
640 WrapLogEnter("CMenuBand<%p>::TranslateAcceleratorIO(LPMSG lpMsg=%p)\n", this, lpMsg);
641 if (lpMsg) WrapLogMsg("*lpMsg=%s\n", Wrap(*lpMsg));
642 HRESULT hr = m_IInputObject->TranslateAcceleratorIO(lpMsg);
643 WrapLogExit("CMenuBand::TranslateAcceleratorIO() = %08x\n", hr);
644 return hr;
645 }
646
647 // *** IPersistStream methods ***
648 HRESULT STDMETHODCALLTYPE CMenuBand::IsDirty()
649 {
650 WrapLogEnter("CMenuBand<%p>::IsDirty()\n", this);
651 HRESULT hr = m_IPersistStream->IsDirty();
652 WrapLogExit("CMenuBand::IsDirty() = %08x\n", hr);
653 return hr;
654 }
655 HRESULT STDMETHODCALLTYPE CMenuBand::Load(IStream *pStm)
656 {
657 WrapLogEnter("CMenuBand<%p>::Load(IStream *pStm=%p)\n", this, pStm);
658 HRESULT hr = m_IPersistStream->Load(pStm);
659 WrapLogExit("CMenuBand::Load() = %08x\n", hr);
660 return hr;
661 }
662 HRESULT STDMETHODCALLTYPE CMenuBand::Save(IStream *pStm, BOOL fClearDirty)
663 {
664 WrapLogEnter("CMenuBand<%p>::Save(IStream *pStm=%p, BOOL fClearDirty=%d)\n", this, pStm, fClearDirty);
665 HRESULT hr = m_IPersistStream->Save(pStm, fClearDirty);
666 WrapLogExit("CMenuBand::Save() = %08x\n", hr);
667 return hr;
668 }
669 HRESULT STDMETHODCALLTYPE CMenuBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
670 {
671 WrapLogEnter("CMenuBand<%p>::GetSizeMax(ULARGE_INTEGER *pcbSize=%p)\n", this, pcbSize);
672 HRESULT hr = m_IPersistStream->GetSizeMax(pcbSize);
673 WrapLogExit("CMenuBand::GetSizeMax() = %08x\n", hr);
674 return hr;
675 }
676
677 // *** IPersist methods ***
678 HRESULT STDMETHODCALLTYPE CMenuBand::GetClassID(CLSID *pClassID)
679 {
680 WrapLogEnter("CMenuBand<%p>::GetClassID(CLSID *pClassID=%p)\n", this, pClassID);
681 HRESULT hr = m_IPersist->GetClassID(pClassID);
682 if (pClassID) WrapLogMsg("*pClassID=%s\n", Wrap(*pClassID));
683 WrapLogExit("CMenuBand::GetClassID() = %08x\n", hr);
684 return hr;
685 }
686
687 // *** IOleCommandTarget methods ***
688 HRESULT STDMETHODCALLTYPE CMenuBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
689 {
690 WrapLogEnter("CMenuBand<%p>::QueryStatus(const GUID *pguidCmdGroup=%p, ULONG cCmds=%u, prgCmds=%p, pCmdText=%p)\n", this, pguidCmdGroup, cCmds, prgCmds, pCmdText);
691 HRESULT hr = m_IOleCommandTarget->QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText);
692 if (pguidCmdGroup) WrapLogMsg("*pguidCmdGroup=%s\n", Wrap(*pguidCmdGroup));
693 WrapLogExit("CMenuBand::QueryStatus() = %08x\n", hr);
694 return hr;
695 }
696
697 HRESULT STDMETHODCALLTYPE CMenuBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
698 {
699 bool b;
700
701 WrapLogEnter("CMenuBand<%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);
702
703 if (pguidCmdGroup && IsEqualGUID(*pguidCmdGroup, CLSID_MenuBand))
704 {
705 if (nCmdID == 19) // popup
706 {
707 b = true;
708 }
709 }
710
711
712 if (pguidCmdGroup) WrapLogMsg("*pguidCmdGroup=%s\n", Wrap(*pguidCmdGroup));
713 HRESULT hr = m_IOleCommandTarget->Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
714 WrapLogExit("CMenuBand::Exec() = %08x\n", hr);
715 return hr;
716 }
717
718 // *** IServiceProvider methods ***
719 HRESULT STDMETHODCALLTYPE CMenuBand::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
720 {
721 WrapLogEnter("CMenuBand<%p>::QueryService(REFGUID guidService=%s, REFIID riid=%s, void **ppvObject=%p)\n", this, Wrap(guidService), Wrap(riid), ppvObject);
722
723 if (IsEqualIID(guidService, SID_SMenuBandChild))
724 {
725 WrapLogMsg("SID is SID_SMenuBandChild. Using QueryInterface of self instead of wrapped object.\n");
726 HRESULT hr = this->QueryInterface(riid, ppvObject);
727 if (ppvObject) WrapLogMsg("*ppvObject=%p\n", *ppvObject);
728 WrapLogExit("CMenuBand::QueryService() = %08x\n", hr);
729 return hr;
730 }
731 else
732 {
733 WrapLogMsg("SID not identified.\n");
734 }
735 HRESULT hr = m_IServiceProvider->QueryService(guidService, riid, ppvObject);
736 if (ppvObject) WrapLogMsg("*ppvObject=%p\n", *ppvObject);
737 WrapLogExit("CMenuBand::QueryService() = %08x\n", hr);
738 return hr;
739 }
740
741
742 // *** IMenuPopup methods ***
743 HRESULT STDMETHODCALLTYPE CMenuBand::Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags)
744 {
745 WrapLogEnter("CMenuBand<%p>::Popup(POINTL *ppt=%p, RECTL *prcExclude=%p, MP_POPUPFLAGS dwFlags=%08x)\n", this, ppt, prcExclude, dwFlags);
746 HRESULT hr = m_IMenuPopup->Popup(ppt, prcExclude, dwFlags);
747 WrapLogExit("CMenuBand::Popup() = %08x\n", hr);
748 return hr;
749 }
750
751 HRESULT STDMETHODCALLTYPE CMenuBand::OnSelect(DWORD dwSelectType)
752 {
753 WrapLogEnter("CMenuBand<%p>::OnSelect(DWORD dwSelectType=%08x)\n", this, dwSelectType);
754 HRESULT hr = m_IMenuPopup->OnSelect(dwSelectType);
755 WrapLogExit("CMenuBand::OnSelect() = %08x\n", hr);
756 return hr;
757 }
758
759 HRESULT STDMETHODCALLTYPE CMenuBand::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
760 {
761 WrapLogEnter("CMenuBand<%p>::SetSubMenu(IMenuPopup *pmp=%p, BOOL fSet=%d)\n", this, pmp, fSet);
762 HRESULT hr = m_IMenuPopup->SetSubMenu(pmp, fSet);
763 WrapLogExit("CMenuBand::SetSubMenu() = %08x\n", hr);
764 return hr;
765 }
766
767
768 // *** IDeskBar methods ***
769 HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
770 {
771 WrapLogEnter("CMenuBand<%p>::SetClient(IUnknown *punkClient=%p)\n", this, punkClient);
772 HRESULT hr = m_IDeskBar->SetClient(punkClient);
773 WrapLogExit("CMenuBand::SetClient() = %08x\n", hr);
774 return hr;
775 }
776
777 HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
778 {
779 WrapLogEnter("CMenuBand<%p>::GetClient(IUnknown **ppunkClient=%p)\n", this, ppunkClient);
780 HRESULT hr = m_IDeskBar->GetClient(ppunkClient);
781 if (ppunkClient) WrapLogMsg("*ppunkClient=%p\n", *ppunkClient);
782 WrapLogExit("CMenuBand::GetClient() = %08x\n", hr);
783 return hr;
784 }
785
786 HRESULT STDMETHODCALLTYPE CMenuBand::OnPosRectChangeDB(RECT *prc)
787 {
788 WrapLogEnter("CMenuBand<%p>::OnPosRectChangeDB(RECT *prc=%p)\n", this, prc);
789 HRESULT hr = m_IDeskBar->OnPosRectChangeDB(prc);
790 if (prc) WrapLogMsg("*prc=%s\n", Wrap(*prc));
791 WrapLogExit("CMenuBand::OnPosRectChangeDB() = %08x\n", hr);
792 return hr;
793 }
794
795
796 // *** IMenuBand methods ***
797 HRESULT STDMETHODCALLTYPE CMenuBand::IsMenuMessage(MSG *pmsg)
798 {
799 //WrapLogEnter("CMenuBand<%p>::IsMenuMessage(MSG *pmsg=%p)\n", this, pmsg);
800 HRESULT hr = m_IMenuBand->IsMenuMessage(pmsg);
801 //WrapLogExit("CMenuBand::IsMenuMessage() = %08x\n", hr);
802 return hr;
803 }
804
805 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateMenuMessage(MSG *pmsg, LRESULT *plRet)
806 {
807 //WrapLogEnter("CMenuBand<%p>::TranslateMenuMessage(MSG *pmsg=%p, LRESULT *plRet=%p)\n", this, pmsg, plRet);
808 HRESULT hr = m_IMenuBand->TranslateMenuMessage(pmsg, plRet);
809 //WrapLogExit("CMenuBand::TranslateMenuMessage(*plRet=%d) = %08x\n", *plRet, hr);
810 return hr;
811 }
812
813 // *** IShellMenu methods ***
814 HRESULT STDMETHODCALLTYPE CMenuBand::Initialize(IShellMenuCallback *psmc, UINT uId, UINT uIdAncestor, DWORD dwFlags)
815 {
816 WrapLogEnter("CMenuBand<%p>::Initialize(IShellMenuCallback *psmc=%p, UINT uId=%u, UINT uIdAncestor=%u, DWORD dwFlags=%08x)\n", this, psmc, uId, uIdAncestor, dwFlags);
817 HRESULT hr = m_IShellMenu->Initialize(psmc, uId, uIdAncestor, dwFlags);
818 WrapLogExit("CMenuBand::Initialize() = %08x\n", hr);
819 return hr;
820 }
821
822 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags)
823 {
824 WrapLogEnter("CMenuBand<%p>::GetMenuInfo(IShellMenuCallback **ppsmc=%p, UINT *puId=%p, UINT *puIdAncestor=%p, DWORD *pdwFlags=%p)\n", this, ppsmc, puId, puIdAncestor, pdwFlags);
825 HRESULT hr = m_IShellMenu->GetMenuInfo(ppsmc, puId, puIdAncestor, pdwFlags);
826 if (ppsmc) WrapLogMsg("*ppsmc=%p\n", *ppsmc);
827 if (puId) WrapLogMsg("*puId=%u\n", *puId);
828 if (puIdAncestor) WrapLogMsg("*puIdAncestor=%u\n", *puIdAncestor);
829 if (pdwFlags) WrapLogMsg("*pdwFlags=%08x\n", *pdwFlags);
830 WrapLogExit("CMenuBand::GetMenuInfo() = %08x\n", hr);
831 return hr;
832 }
833
834 HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
835 {
836 WrapLogEnter("CMenuBand<%p>::SetShellFolder(IShellFolder *psf=%p, LPCITEMIDLIST pidlFolder=%p, HKEY hKey=%p, DWORD dwFlags=%08x)\n", this, psf, pidlFolder, hKey, dwFlags);
837 HRESULT hr = m_IShellMenu->SetShellFolder(psf, pidlFolder, hKey, dwFlags);
838 WrapLogExit("CMenuBand::SetShellFolder() = %08x\n", hr);
839 return hr;
840 }
841
842 HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
843 {
844 WrapLogEnter("CMenuBand<%p>::GetShellFolder(DWORD *pdwFlags=%p, LPITEMIDLIST *ppidl=%p, REFIID riid=%s, void **ppv=%p)\n", this, pdwFlags, ppidl, Wrap(riid), ppv);
845 HRESULT hr = m_IShellMenu->GetShellFolder(pdwFlags, ppidl, riid, ppv);
846 if (pdwFlags) WrapLogMsg("*pdwFlags=%08x\n", *pdwFlags);
847 if (ppidl) WrapLogMsg("*ppidl=%p\n", *ppidl);
848 if (ppv) WrapLogMsg("*ppv=%p\n", *ppv);
849 WrapLogExit("CMenuBand::GetShellFolder() = %08x\n", hr);
850 return hr;
851 }
852
853 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags)
854 {
855 WrapLogEnter("CMenuBand<%p>::SetMenu(HMENU hmenu=%p, HWND hwnd=%p, DWORD dwFlags=%08x)\n", this, hmenu, hwnd, dwFlags);
856 HRESULT hr = m_IShellMenu->SetMenu(hmenu, hwnd, dwFlags);
857 WrapLogExit("CMenuBand::SetMenu() = %08x\n", hr);
858 return hr;
859 }
860
861 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags)
862 {
863 WrapLogEnter("CMenuBand<%p>::GetMenu(HMENU *phmenu=%p, HWND *phwnd=%p, DWORD *pdwFlags=%p)\n", this, phmenu, phwnd, pdwFlags);
864 HRESULT hr = m_IShellMenu->GetMenu(phmenu, phwnd, pdwFlags);
865 if (phmenu) WrapLogMsg("*phmenu=%p\n", *phmenu);
866 if (phwnd) WrapLogMsg("*phwnd=%p\n", *phwnd);
867 if (pdwFlags) WrapLogMsg("*pdwFlags=%08x\n", *pdwFlags);
868 WrapLogExit("CMenuBand::GetMenu() = %08x\n", hr);
869 return hr;
870 }
871
872 HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
873 {
874 WrapLogEnter("CMenuBand<%p>::InvalidateItem(LPSMDATA psmd=%p, DWORD dwFlags=%08x)\n", this, psmd, dwFlags);
875 HRESULT hr = m_IShellMenu->InvalidateItem(psmd, dwFlags);
876 WrapLogExit("CMenuBand::InvalidateItem() = %08x\n", hr);
877 return hr;
878 }
879
880 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(LPSMDATA psmd)
881 {
882 WrapLogEnter("CMenuBand<%p>::GetState(LPSMDATA psmd=%p)\n", this, psmd);
883 HRESULT hr = m_IShellMenu->GetState(psmd);
884 WrapLogExit("CMenuBand::GetState() = %08x\n", hr);
885 return hr;
886 }
887
888 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
889 {
890 WrapLogEnter("CMenuBand<%p>::SetMenuToolbar(IUnknown *punk=%p, DWORD dwFlags=%08x)\n", this, punk, dwFlags);
891 HRESULT hr = m_IShellMenu->SetMenuToolbar(punk, dwFlags);
892 WrapLogExit("CMenuBand::SetMenuToolbar() = %08x\n", hr);
893 return hr;
894 }
895 #else
896
897 #include <windowsx.h>
898
899 #define TBSTYLE_EX_VERTICAL 4
900
901 CMenuToolbarBase::CMenuToolbarBase(CMenuBand *menuBand) :
902 m_menuBand(menuBand),
903 m_hwnd(NULL),
904 m_dwMenuFlags(0)
905 {
906 }
907
908 HRESULT CMenuToolbarBase::ShowWindow(BOOL fShow)
909 {
910 ::ShowWindow(m_hwnd, fShow ? SW_SHOW : SW_HIDE);
911
912 HIMAGELIST ilBig, ilSmall;
913 Shell_GetImageLists(&ilBig, &ilSmall);
914
915 if (m_menuBand->UseBigIcons())
916 {
917 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, (LPARAM) ilBig);
918 }
919 else
920 {
921 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, (LPARAM) ilSmall);
922 }
923
924 return S_OK;
925 }
926
927 HRESULT CMenuToolbarBase::Close()
928 {
929 DestroyWindow(m_hwnd);
930 m_hwnd = NULL;
931 return S_OK;
932 }
933
934 HRESULT CMenuToolbarBase::CreateToolbar(HWND hwndParent, DWORD dwFlags)
935 {
936 LONG tbStyles = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
937 TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | TBSTYLE_REGISTERDROP | TBSTYLE_LIST | TBSTYLE_FLAT | TBSTYLE_CUSTOMERASE |
938 CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_TOP;
939 LONG tbExStyles = TBSTYLE_EX_DOUBLEBUFFER;
940
941 if (dwFlags & SMINIT_VERTICAL)
942 {
943 tbStyles |= CCS_VERT;
944 tbExStyles |= TBSTYLE_EX_VERTICAL;
945 }
946
947 RECT rc;
948
949 if (!::GetClientRect(hwndParent, &rc) || (rc.left == rc.right) || (rc.top == rc.bottom))
950 {
951 rc.left = 0;
952 rc.top = 0;
953 rc.right = 1;
954 rc.bottom = 1;
955 }
956
957 HWND hwndToolbar = CreateWindowEx(
958 tbExStyles, TOOLBARCLASSNAMEW, NULL,
959 tbStyles, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
960 hwndParent, NULL, _AtlBaseModule.GetModuleInstance(), 0);
961
962 if (hwndToolbar == NULL)
963 return E_FAIL;
964
965 ::SetParent(hwndToolbar, hwndParent);
966
967 m_hwnd = hwndToolbar;
968
969 /* Identify the version of the used Common Controls DLL by sending the size of the TBBUTTON structure */
970 SendMessageW(m_hwnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
971
972 HIMAGELIST ilBig, ilSmall;
973 Shell_GetImageLists(&ilBig, &ilSmall);
974
975 //if (dwFlags & SMINIT_TOPLEVEL)
976 //{
977 // /* Hide the placeholders for the button images */
978 // SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, 0);
979 //}
980 //else
981 if (m_menuBand->UseBigIcons())
982 {
983 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, (LPARAM) ilBig);
984 }
985 else
986 {
987 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, (LPARAM) ilSmall);
988 }
989
990 return S_OK;
991 }
992
993 HRESULT CMenuToolbarBase::GetWindow(HWND *phwnd)
994 {
995 if (!phwnd)
996 return E_FAIL;
997
998 *phwnd = m_hwnd;
999
1000 return S_OK;
1001 }
1002
1003 BOOL
1004 AllocAndGetMenuString(HMENU hMenu, UINT ItemIDByPosition, WCHAR** String)
1005 {
1006 int Length;
1007
1008 Length = GetMenuStringW(hMenu, ItemIDByPosition, NULL, 0, MF_BYPOSITION);
1009
1010 if (!Length)
1011 return FALSE;
1012
1013 /* Also allocate space for the terminating NULL character */
1014 ++Length;
1015 *String = (PWSTR) HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR));
1016
1017 GetMenuStringW(hMenu, ItemIDByPosition, *String, Length, MF_BYPOSITION);
1018
1019 return TRUE;
1020 }
1021
1022 CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand) :
1023 CMenuToolbarBase(menuBand),
1024 m_hmenu(NULL)
1025 {
1026 }
1027
1028 HRESULT CMenuStaticToolbar::GetMenu(
1029 HMENU *phmenu,
1030 HWND *phwnd,
1031 DWORD *pdwFlags)
1032 {
1033 *phmenu = m_hmenu;
1034 *phwnd = NULL;
1035 *pdwFlags = m_dwMenuFlags;
1036
1037 return S_OK;
1038 }
1039
1040 HRESULT CMenuStaticToolbar::SetMenu(
1041 HMENU hmenu,
1042 HWND hwnd,
1043 DWORD dwFlags)
1044 {
1045 m_hmenu = hmenu;
1046 m_dwMenuFlags = dwFlags;
1047
1048 return S_OK;
1049 }
1050
1051 HRESULT CMenuStaticToolbar::FillToolbar()
1052 {
1053 int i;
1054 PWSTR MenuString;
1055
1056 int ic = GetMenuItemCount(m_hmenu);
1057
1058 for (i = 0; i < ic; i++)
1059 {
1060 MENUITEMINFOW info;
1061 TBBUTTON tbb = { 0 };
1062 tbb.fsState = TBSTATE_ENABLED;
1063 tbb.fsStyle = BTNS_AUTOSIZE;
1064
1065 info.cbSize = sizeof(info);
1066 info.fMask = MIIM_FTYPE | MIIM_ID;
1067
1068 GetMenuItemInfoW(m_hmenu, i, TRUE, &info);
1069
1070 if (info.fType == MFT_STRING)
1071 {
1072 if (!AllocAndGetMenuString(m_hmenu, i, &MenuString))
1073 return E_OUTOFMEMORY;
1074 tbb.fsStyle |= BTNS_DROPDOWN;
1075 }
1076 else
1077 {
1078 MenuString = L"";
1079 tbb.fsStyle |= BTNS_SEP;
1080 }
1081
1082 tbb.idCommand = info.wID;
1083 tbb.iString = (INT_PTR) MenuString;
1084
1085 SMINFO sminfo;
1086 if (info.wID >= 0 && SUCCEEDED(m_menuBand->CallCBWithId(info.wID, SMC_GETINFO, 0, (LPARAM) &sminfo)))
1087 {
1088 tbb.iBitmap = sminfo.iIcon;
1089 }
1090
1091 SendMessageW(m_hwnd, TB_ADDBUTTONS, 1, (LPARAM) (LPTBBUTTON) &tbb);
1092 HeapFree(GetProcessHeap(), 0, MenuString);
1093 }
1094
1095 return S_OK;
1096 }
1097
1098 CMenuSFToolbar::CMenuSFToolbar(CMenuBand * menuBand) :
1099 CMenuToolbarBase(menuBand),
1100 m_shellFolder(NULL)
1101 {
1102 }
1103
1104 CMenuSFToolbar::~CMenuSFToolbar()
1105 {
1106 }
1107
1108 HRESULT CMenuSFToolbar::FillToolbar()
1109 {
1110 HRESULT hr;
1111 TBBUTTON tbb = { 0 };
1112 int i = 0;
1113 PWSTR MenuString;
1114
1115 tbb.fsState = TBSTATE_ENABLED;
1116 tbb.fsStyle = BTNS_DROPDOWN | BTNS_AUTOSIZE;
1117
1118 IEnumIDList * eidl;
1119 m_shellFolder->EnumObjects(m_hwnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &eidl);
1120
1121 LPITEMIDLIST item = (LPITEMIDLIST) CoTaskMemAlloc(sizeof(ITEMIDLIST));
1122 ULONG fetched;
1123 while ((hr = eidl->Next(1, &item, &fetched)) == S_OK)
1124 {
1125 INT index = 0;
1126 INT indexOpen = 0;
1127
1128 IShellItem *psi;
1129 SHCreateShellItem(NULL, m_shellFolder, item, &psi);
1130
1131 hr = psi->GetDisplayName(SIGDN_NORMALDISPLAY, &MenuString);
1132 if (FAILED(hr))
1133 return hr;
1134
1135 index = SHMapPIDLToSystemImageListIndex(m_shellFolder, item, &indexOpen);
1136
1137 tbb.idCommand = i++;
1138 tbb.iString = (INT_PTR) MenuString;
1139 tbb.iBitmap = index;
1140
1141 SendMessageW(m_hwnd, TB_ADDBUTTONS, 1, (LPARAM) (LPTBBUTTON) &tbb);
1142 HeapFree(GetProcessHeap(), 0, MenuString);
1143
1144 }
1145 CoTaskMemFree(item);
1146
1147 return hr;
1148 }
1149
1150 HRESULT CMenuSFToolbar::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
1151 {
1152 m_shellFolder = psf;
1153 m_idList = pidlFolder;
1154 m_hKey = hKey;
1155 m_dwMenuFlags = dwFlags;
1156 return S_OK;
1157 }
1158
1159 HRESULT CMenuSFToolbar::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
1160 {
1161 HRESULT hr;
1162
1163 hr = m_shellFolder->QueryInterface(riid, ppv);
1164 if (FAILED(hr))
1165 return hr;
1166
1167 if (pdwFlags)
1168 *pdwFlags = m_dwMenuFlags;
1169
1170 if (ppidl)
1171 {
1172 LPITEMIDLIST pidl = NULL;
1173
1174 if (m_idList)
1175 {
1176 pidl = ILClone(m_idList);
1177 if (!pidl)
1178 {
1179 (*(IUnknown**) ppv)->Release();
1180 return E_FAIL;
1181 }
1182 }
1183
1184 *ppidl = pidl;
1185 }
1186
1187 return hr;
1188 }
1189
1190 CMenuBand::CMenuBand() :
1191 m_site(NULL),
1192 m_psmc(NULL),
1193 m_staticToolbar(NULL),
1194 m_SFToolbar(NULL),
1195 m_useBigIcons(FALSE)
1196 {
1197 }
1198
1199 CMenuBand::~CMenuBand()
1200 {
1201 if (m_site)
1202 m_site->Release();
1203
1204 if (m_psmc)
1205 m_psmc->Release();
1206
1207 if (m_staticToolbar)
1208 delete m_staticToolbar;
1209
1210 if (m_SFToolbar)
1211 delete m_SFToolbar;
1212 }
1213
1214 HRESULT STDMETHODCALLTYPE CMenuBand::Initialize(
1215 IShellMenuCallback *psmc,
1216 UINT uId,
1217 UINT uIdAncestor,
1218 DWORD dwFlags)
1219 {
1220 if (m_psmc)
1221 m_psmc->Release();
1222
1223 m_psmc = psmc;
1224 m_uId = uId;
1225 m_uIdAncestor = uIdAncestor;
1226 m_dwFlags = dwFlags;
1227
1228 if (m_psmc)
1229 {
1230 m_psmc->AddRef();
1231
1232 _CallCB(SMC_CREATE, 0, (LPARAM) &m_UserData);
1233 }
1234
1235 return S_OK;
1236 }
1237
1238 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenuInfo(
1239 IShellMenuCallback **ppsmc,
1240 UINT *puId,
1241 UINT *puIdAncestor,
1242 DWORD *pdwFlags)
1243 {
1244 if (!pdwFlags) // maybe?
1245 return E_INVALIDARG;
1246
1247 if (ppsmc)
1248 *ppsmc = m_psmc;
1249
1250 if (puId)
1251 *puId = m_uId;
1252
1253 if (puIdAncestor)
1254 *puIdAncestor = m_uIdAncestor;
1255
1256 *pdwFlags = m_dwFlags;
1257
1258 return S_OK;
1259 }
1260
1261 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenu(
1262 HMENU hmenu,
1263 HWND hwnd,
1264 DWORD dwFlags)
1265 {
1266 if (m_staticToolbar == NULL)
1267 {
1268 m_staticToolbar = new CMenuStaticToolbar(this);
1269 }
1270 m_hmenu = hmenu;
1271
1272 HRESULT hResult = m_staticToolbar->SetMenu(hmenu, hwnd, dwFlags);
1273 if (FAILED(hResult))
1274 return hResult;
1275
1276 if (m_site)
1277 {
1278 HWND hwndParent;
1279
1280 hResult = m_site->GetWindow(&hwndParent);
1281 if (FAILED(hResult))
1282 return hResult;
1283
1284 hResult = m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
1285 if (FAILED(hResult))
1286 return hResult;
1287
1288 hResult = m_staticToolbar->FillToolbar();
1289 }
1290
1291 return hResult;
1292 }
1293
1294 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenu(
1295 HMENU *phmenu,
1296 HWND *phwnd,
1297 DWORD *pdwFlags)
1298 {
1299 if (m_staticToolbar == NULL)
1300 return E_FAIL;
1301
1302 return m_staticToolbar->GetMenu(phmenu, phwnd, pdwFlags);
1303 }
1304
1305 HRESULT STDMETHODCALLTYPE CMenuBand::SetSite(IUnknown *pUnkSite)
1306 {
1307 HWND hwndParent;
1308 HRESULT hResult;
1309
1310 if (m_site != NULL)
1311 m_site->Release();
1312
1313 if (pUnkSite == NULL)
1314 return S_OK;
1315
1316 hwndParent = NULL;
1317 hResult = pUnkSite->QueryInterface(IID_PPV_ARG(IOleWindow, &m_site));
1318 if (SUCCEEDED(hResult))
1319 {
1320 m_site->GetWindow(&hwndParent);
1321 m_site->Release();
1322 }
1323 if (!::IsWindow(hwndParent))
1324 return E_FAIL;
1325
1326 if (m_staticToolbar != NULL)
1327 {
1328 hResult = m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
1329 if (FAILED(hResult))
1330 return hResult;
1331
1332 hResult = m_staticToolbar->FillToolbar();
1333 }
1334
1335 if (m_SFToolbar != NULL)
1336 {
1337 hResult = m_SFToolbar->CreateToolbar(hwndParent, m_dwFlags);
1338 if (FAILED(hResult))
1339 return hResult;
1340
1341 hResult = m_SFToolbar->FillToolbar();
1342 }
1343
1344 return S_OK;
1345 }
1346
1347 HRESULT STDMETHODCALLTYPE CMenuBand::GetSite(REFIID riid, PVOID *ppvSite)
1348 {
1349 if (m_site == NULL)
1350 return E_FAIL;
1351
1352 return m_site->QueryInterface(riid, ppvSite);
1353 }
1354
1355 HRESULT STDMETHODCALLTYPE CMenuBand::GetWindow(
1356 HWND *phwnd)
1357 {
1358 if (m_SFToolbar != NULL)
1359 return m_SFToolbar->GetWindow(phwnd);
1360
1361 if (m_staticToolbar != NULL)
1362 return m_staticToolbar->GetWindow(phwnd);
1363
1364 return E_FAIL;
1365 }
1366
1367 HRESULT STDMETHODCALLTYPE CMenuBand::OnPosRectChangeDB(RECT *prc)
1368 {
1369 SIZE sizeStaticX = { 0 };
1370 SIZE sizeShlFldX = { 0 };
1371 SIZE sizeStaticY = { 0 };
1372 SIZE sizeShlFldY = { 0 };
1373 HWND hwndStatic = NULL;
1374 HWND hwndShlFld = NULL;
1375 HRESULT hResult = S_OK;
1376
1377 if (m_staticToolbar != NULL)
1378 hResult = m_staticToolbar->GetWindow(&hwndStatic);
1379 if (FAILED(hResult))
1380 return hResult;
1381
1382 if (m_SFToolbar != NULL)
1383 hResult = m_SFToolbar->GetWindow(&hwndShlFld);
1384 if (FAILED(hResult))
1385 return hResult;
1386
1387 if (hwndStatic == NULL && hwndShlFld == NULL)
1388 return E_FAIL;
1389
1390 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeStaticY);
1391 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeShlFldY);
1392 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, FALSE, (LPARAM) &sizeStaticX);
1393 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, FALSE, (LPARAM) &sizeShlFldX);
1394
1395 int sy = max(prc->bottom - prc->top, sizeStaticY.cy + sizeShlFldY.cy);
1396
1397 if (hwndShlFld) SetWindowPos(hwndShlFld, NULL,
1398 prc->left,
1399 prc->top,
1400 prc->right - prc->left,
1401 sizeShlFldY.cy,
1402 0);
1403 if (hwndStatic) SetWindowPos(hwndStatic, hwndShlFld,
1404 prc->left,
1405 prc->top + sizeShlFldY.cy,
1406 prc->right - prc->left,
1407 sy - sizeShlFldY.cy,
1408 0);
1409
1410 return S_OK;
1411 }
1412
1413 HRESULT STDMETHODCALLTYPE CMenuBand::GetBandInfo(
1414 DWORD dwBandID,
1415 DWORD dwViewMode,
1416 DESKBANDINFO *pdbi)
1417 {
1418 HWND hwndStatic = NULL;
1419 HWND hwndShlFld = NULL;
1420 HRESULT hResult = S_OK;
1421
1422 if (m_staticToolbar != NULL)
1423 hResult = m_staticToolbar->GetWindow(&hwndStatic);
1424 if (FAILED(hResult))
1425 return hResult;
1426
1427 if (m_SFToolbar != NULL)
1428 hResult = m_SFToolbar->GetWindow(&hwndShlFld);
1429 if (FAILED(hResult))
1430 return hResult;
1431
1432 if (hwndStatic == NULL && hwndShlFld == NULL)
1433 return E_FAIL;
1434
1435 // HACK (?)
1436 if (pdbi->dwMask == 0)
1437 {
1438 pdbi->dwMask = DBIM_MINSIZE | DBIM_MAXSIZE | DBIM_INTEGRAL | DBIM_ACTUAL | DBIM_TITLE | DBIM_MODEFLAGS | DBIM_BKCOLOR;
1439 }
1440
1441 if (pdbi->dwMask & DBIM_MINSIZE)
1442 {
1443 SIZE sizeStatic = { 0 };
1444 SIZE sizeShlFld = { 0 };
1445
1446 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeStatic);
1447 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeShlFld);
1448
1449 pdbi->ptMinSize.x = 0;
1450 pdbi->ptMinSize.y = sizeStatic.cy + sizeShlFld.cy;
1451 }
1452 if (pdbi->dwMask & DBIM_MAXSIZE)
1453 {
1454 SIZE sizeStatic = { 0 };
1455 SIZE sizeShlFld = { 0 };
1456
1457 if (hwndStatic) SendMessageW(hwndStatic, TB_GETMAXSIZE, 0, (LPARAM) &sizeStatic);
1458 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETMAXSIZE, 0, (LPARAM) &sizeShlFld);
1459
1460 pdbi->ptMaxSize.x = sizeStatic.cx + sizeShlFld.cx; // ignored
1461 pdbi->ptMaxSize.y = sizeStatic.cy + sizeShlFld.cy;
1462 }
1463 if (pdbi->dwMask & DBIM_INTEGRAL)
1464 {
1465 pdbi->ptIntegral.x = 0;
1466 pdbi->ptIntegral.y = 0;
1467 }
1468 if (pdbi->dwMask & DBIM_ACTUAL)
1469 {
1470 SIZE sizeStatic = { 0 };
1471 SIZE sizeShlFld = { 0 };
1472
1473 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, FALSE, (LPARAM) &sizeStatic);
1474 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, FALSE, (LPARAM) &sizeShlFld);
1475 pdbi->ptActual.x = sizeStatic.cx + sizeShlFld.cx;
1476
1477 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeStatic);
1478 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeShlFld);
1479 pdbi->ptActual.y = sizeStatic.cy + sizeShlFld.cy;
1480 }
1481 if (pdbi->dwMask & DBIM_TITLE)
1482 wcscpy(pdbi->wszTitle, L"");
1483 if (pdbi->dwMask & DBIM_MODEFLAGS)
1484 pdbi->dwModeFlags = DBIMF_UNDELETEABLE;
1485 if (pdbi->dwMask & DBIM_BKCOLOR)
1486 pdbi->crBkgnd = 0;
1487 return S_OK;
1488 }
1489
1490 /* IDockingWindow */
1491 HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
1492 {
1493 HRESULT hr = S_OK;
1494
1495 if (m_staticToolbar != NULL)
1496 hr = m_staticToolbar->ShowWindow(fShow);
1497 if (FAILED(hr))
1498 return hr;
1499 if (m_SFToolbar != NULL)
1500 hr = m_SFToolbar->ShowWindow(fShow);
1501 if (FAILED(hr))
1502 return hr;
1503
1504 if (fShow)
1505 return _CallCB(SMC_INITMENU, 0, 0);
1506
1507 return S_OK;
1508 }
1509
1510 HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
1511 {
1512 ShowDW(FALSE);
1513
1514 if (m_staticToolbar != NULL)
1515 return m_staticToolbar->Close();
1516
1517 if (m_SFToolbar != NULL)
1518 return m_SFToolbar->Close();
1519
1520 return S_OK;
1521 }
1522 HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
1523 {
1524 UNIMPLEMENTED;
1525 return S_OK;
1526 }
1527
1528 HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
1529 {
1530 UNIMPLEMENTED;
1531 return S_OK;
1532 }
1533
1534 HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
1535 {
1536 UNIMPLEMENTED;
1537 return S_OK;
1538 }
1539
1540 HRESULT STDMETHODCALLTYPE CMenuBand::HasFocusIO()
1541 {
1542 UNIMPLEMENTED;
1543 return S_OK;
1544 }
1545
1546 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateAcceleratorIO(LPMSG lpMsg)
1547 {
1548 UNIMPLEMENTED;
1549 return S_OK;
1550 }
1551
1552 HRESULT STDMETHODCALLTYPE CMenuBand::IsDirty()
1553 {
1554 UNIMPLEMENTED;
1555 return S_OK;
1556 }
1557
1558 HRESULT STDMETHODCALLTYPE CMenuBand::Load(IStream *pStm)
1559 {
1560 UNIMPLEMENTED;
1561 return S_OK;
1562 }
1563
1564 HRESULT STDMETHODCALLTYPE CMenuBand::Save(IStream *pStm, BOOL fClearDirty)
1565 {
1566 UNIMPLEMENTED;
1567 return S_OK;
1568 }
1569
1570 HRESULT STDMETHODCALLTYPE CMenuBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
1571 {
1572 UNIMPLEMENTED;
1573 return S_OK;
1574 }
1575
1576 HRESULT STDMETHODCALLTYPE CMenuBand::GetClassID(CLSID *pClassID)
1577 {
1578 UNIMPLEMENTED;
1579 return S_OK;
1580 }
1581
1582 HRESULT STDMETHODCALLTYPE CMenuBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
1583 {
1584 UNIMPLEMENTED;
1585 return S_OK;
1586 }
1587
1588 HRESULT STDMETHODCALLTYPE CMenuBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1589 {
1590 if (!pguidCmdGroup)
1591 return E_FAIL;
1592
1593 if (IsEqualGUID(*pguidCmdGroup, CLSID_MenuBand))
1594 {
1595 if (nCmdID == 16) // set (big) icon size
1596 {
1597 this->m_useBigIcons = TRUE;
1598 return S_OK;
1599 }
1600 else if (nCmdID == 19) // popup-related
1601 {
1602 return S_FALSE;
1603 }
1604 }
1605
1606 UNIMPLEMENTED;
1607 return S_OK;
1608 }
1609
1610 HRESULT STDMETHODCALLTYPE CMenuBand::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
1611 {
1612 if (IsEqualIID(guidService, SID_SMenuBandChild))
1613 return this->QueryInterface(riid, ppvObject);
1614 WARN("Unknown service requested %s\n", wine_dbgstr_guid(&guidService));
1615 return E_NOINTERFACE;
1616 }
1617
1618 HRESULT STDMETHODCALLTYPE CMenuBand::Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags)
1619 {
1620 UNIMPLEMENTED;
1621 return S_OK;
1622 }
1623
1624 HRESULT STDMETHODCALLTYPE CMenuBand::OnSelect(DWORD dwSelectType)
1625 {
1626 UNIMPLEMENTED;
1627 return S_OK;
1628 }
1629
1630 HRESULT STDMETHODCALLTYPE CMenuBand::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
1631 {
1632 UNIMPLEMENTED;
1633 return S_OK;
1634 }
1635
1636 HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
1637 {
1638 UNIMPLEMENTED;
1639 return S_OK;
1640 }
1641
1642 HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
1643 {
1644 UNIMPLEMENTED;
1645 return S_OK;
1646 }
1647
1648 HRESULT STDMETHODCALLTYPE CMenuBand::IsMenuMessage(MSG *pmsg)
1649 {
1650 //UNIMPLEMENTED;
1651 //return S_OK;
1652 return S_FALSE;
1653 //return E_NOTIMPL;
1654 }
1655
1656 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateMenuMessage(MSG *pmsg, LRESULT *plRet)
1657 {
1658 //UNIMPLEMENTED;
1659 return S_FALSE;
1660 }
1661
1662 HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
1663 {
1664 if (m_SFToolbar == NULL)
1665 {
1666 m_SFToolbar = new CMenuSFToolbar(this);
1667 }
1668
1669 HRESULT hResult = m_SFToolbar->SetShellFolder(psf, pidlFolder, hKey, dwFlags);
1670 if (FAILED(hResult))
1671 return hResult;
1672
1673 if (m_site)
1674 {
1675 HWND hwndParent;
1676
1677 hResult = m_site->GetWindow(&hwndParent);
1678 if (FAILED(hResult))
1679 return hResult;
1680
1681 hResult = m_SFToolbar->CreateToolbar(hwndParent, m_dwFlags);
1682 if (FAILED(hResult))
1683 return hResult;
1684
1685 hResult = m_SFToolbar->FillToolbar();
1686 }
1687
1688 return hResult;
1689 }
1690
1691 HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
1692 {
1693 if (m_SFToolbar)
1694 return m_SFToolbar->GetShellFolder(pdwFlags, ppidl, riid, ppv);
1695 return E_FAIL;
1696 }
1697
1698 HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
1699 {
1700 UNIMPLEMENTED;
1701 return S_OK;
1702 }
1703
1704 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(LPSMDATA psmd)
1705 {
1706 UNIMPLEMENTED;
1707 return S_OK;
1708 }
1709
1710 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
1711 {
1712 UNIMPLEMENTED;
1713 return S_OK;
1714 }
1715
1716 HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
1717 {
1718 UNIMPLEMENTED;
1719 return S_OK;
1720 }
1721
1722 HRESULT STDMETHODCALLTYPE CMenuBand::IsWindowOwner(HWND hWnd)
1723 {
1724 UNIMPLEMENTED;
1725 return S_OK;
1726 }
1727
1728 HRESULT STDMETHODCALLTYPE CMenuBand::GetSubMenu(THIS)
1729 {
1730 UNIMPLEMENTED;
1731 return S_OK;
1732 }
1733
1734 HRESULT STDMETHODCALLTYPE CMenuBand::SetToolbar(THIS)
1735 {
1736 UNIMPLEMENTED;
1737 return S_OK;
1738 }
1739
1740 HRESULT STDMETHODCALLTYPE CMenuBand::SetMinWidth(THIS)
1741 {
1742 UNIMPLEMENTED;
1743 return S_OK;
1744 }
1745
1746 HRESULT STDMETHODCALLTYPE CMenuBand::SetNoBorder(THIS)
1747 {
1748 UNIMPLEMENTED;
1749 return S_OK;
1750 }
1751
1752 HRESULT STDMETHODCALLTYPE CMenuBand::SetTheme(THIS)
1753 {
1754 UNIMPLEMENTED;
1755 return S_OK;
1756 }
1757
1758 HRESULT STDMETHODCALLTYPE CMenuBand::GetTop(THIS)
1759 {
1760 UNIMPLEMENTED;
1761 return S_OK;
1762 }
1763
1764 HRESULT STDMETHODCALLTYPE CMenuBand::GetBottom(THIS)
1765 {
1766 UNIMPLEMENTED;
1767 return S_OK;
1768 }
1769
1770 HRESULT STDMETHODCALLTYPE CMenuBand::GetTracked(THIS)
1771 {
1772 UNIMPLEMENTED;
1773 return S_OK;
1774 }
1775
1776 HRESULT STDMETHODCALLTYPE CMenuBand::GetParentSite(THIS)
1777 {
1778 UNIMPLEMENTED;
1779 return S_OK;
1780 }
1781
1782 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(THIS)
1783 {
1784 UNIMPLEMENTED;
1785 return S_OK;
1786 }
1787
1788 HRESULT STDMETHODCALLTYPE CMenuBand::DoDefaultAction(THIS)
1789 {
1790 UNIMPLEMENTED;
1791 return S_OK;
1792 }
1793
1794 HRESULT STDMETHODCALLTYPE CMenuBand::IsEmpty(THIS)
1795 {
1796 UNIMPLEMENTED;
1797 return S_OK;
1798 }
1799
1800 HRESULT CMenuBand::CallCBWithId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam)
1801 {
1802 if (!m_psmc)
1803 return S_FALSE;
1804
1805 HWND hwnd;
1806 GetWindow(&hwnd);
1807
1808 SMDATA smData = { 0 };
1809 smData.punk = (IShellMenu2*)this;
1810 smData.uId = Id;
1811 smData.uIdParent = m_uId;
1812 smData.uIdAncestor = m_uIdAncestor;
1813 smData.hwnd = hwnd;
1814 if (m_staticToolbar)
1815 {
1816 smData.hmenu = m_hmenu;
1817 }
1818 smData.pvUserData = NULL;
1819 if (m_SFToolbar)
1820 m_SFToolbar->GetShellFolder(NULL, &smData.pidlFolder, IID_PPV_ARG(IShellFolder, &smData.psf));
1821 HRESULT hr = m_psmc->CallbackSM(&smData, uMsg, wParam, lParam);
1822 ILFree(smData.pidlFolder);
1823 if (smData.psf)
1824 smData.psf->Release();
1825 return hr;
1826 }
1827
1828 HRESULT CMenuBand::_CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
1829 {
1830 if (!m_psmc)
1831 return S_FALSE;
1832
1833 HWND hwnd;
1834 GetWindow(&hwnd);
1835
1836 SMDATA smData = { 0 };
1837 smData.punk = (IShellMenu2*)this;
1838 smData.uIdParent = m_uId;
1839 smData.uIdAncestor = m_uIdAncestor;
1840 smData.hwnd = hwnd;
1841 if (m_staticToolbar)
1842 {
1843 smData.hmenu = m_hmenu;
1844 }
1845 smData.pvUserData = NULL;
1846 if (m_SFToolbar)
1847 m_SFToolbar->GetShellFolder(NULL, &smData.pidlFolder, IID_PPV_ARG(IShellFolder, &smData.psf));
1848 HRESULT hr = m_psmc->CallbackSM(&smData, uMsg, wParam, lParam);
1849 ILFree(smData.pidlFolder);
1850 if (smData.psf)
1851 smData.psf->Release();
1852 return hr;
1853 }
1854
1855 #endif