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