[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 |
827 CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_TOP;
828 LONG tbExStyles = TBSTYLE_EX_DOUBLEBUFFER | TBSTYLE_EX_DRAWDDARROWS;
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 = 0;
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 = 0;
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)
1287 {
1288 SetWindowPos(hwndShlFld, NULL,
1289 prc->left,
1290 prc->top,
1291 prc->right - prc->left,
1292 sizeShlFldY.cy,
1293 0);
1294 DWORD btnSize = SendMessage(hwndShlFld, TB_GETBUTTONSIZE, 0, 0);
1295 SendMessage(hwndShlFld, TB_SETBUTTONSIZE, 0, MAKELPARAM(prc->right - prc->left, HIWORD(btnSize)));
1296 }
1297 if (hwndStatic)
1298 {
1299 SetWindowPos(hwndStatic, hwndShlFld,
1300 prc->left,
1301 prc->top + sizeShlFldY.cy,
1302 prc->right - prc->left,
1303 sy - sizeShlFldY.cy,
1304 0);
1305 DWORD btnSize = SendMessage(hwndStatic, TB_GETBUTTONSIZE, 0, 0);
1306 SendMessage(hwndStatic, TB_SETBUTTONSIZE, 0, MAKELPARAM(prc->right - prc->left, HIWORD(btnSize)));
1307 }
1308
1309 return S_OK;
1310 }
1311
1312 HRESULT STDMETHODCALLTYPE CMenuBand::GetBandInfo(
1313 DWORD dwBandID,
1314 DWORD dwViewMode,
1315 DESKBANDINFO *pdbi)
1316 {
1317 HWND hwndStatic = NULL;
1318 HWND hwndShlFld = NULL;
1319 HRESULT hResult = S_OK;
1320
1321 if (m_staticToolbar != NULL)
1322 hResult = m_staticToolbar->GetWindow(&hwndStatic);
1323 if (FAILED(hResult))
1324 return hResult;
1325
1326 if (m_SFToolbar != NULL)
1327 hResult = m_SFToolbar->GetWindow(&hwndShlFld);
1328 if (FAILED(hResult))
1329 return hResult;
1330
1331 if (hwndStatic == NULL && hwndShlFld == NULL)
1332 return E_FAIL;
1333
1334 // HACK (?)
1335 if (pdbi->dwMask == 0)
1336 {
1337 pdbi->dwMask = DBIM_MINSIZE | DBIM_MAXSIZE | DBIM_INTEGRAL | DBIM_ACTUAL | DBIM_TITLE | DBIM_MODEFLAGS | DBIM_BKCOLOR;
1338 }
1339
1340 if (pdbi->dwMask & DBIM_MINSIZE)
1341 {
1342 SIZE sizeStatic = { 0 };
1343 SIZE sizeShlFld = { 0 };
1344
1345 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeStatic);
1346 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeShlFld);
1347
1348 pdbi->ptMinSize.x = 0;
1349 pdbi->ptMinSize.y = sizeStatic.cy + sizeShlFld.cy;
1350 }
1351 if (pdbi->dwMask & DBIM_MAXSIZE)
1352 {
1353 SIZE sizeStatic = { 0 };
1354 SIZE sizeShlFld = { 0 };
1355
1356 if (hwndStatic) SendMessageW(hwndStatic, TB_GETMAXSIZE, 0, (LPARAM) &sizeStatic);
1357 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETMAXSIZE, 0, (LPARAM) &sizeShlFld);
1358
1359 pdbi->ptMaxSize.x = sizeStatic.cx + sizeShlFld.cx; // ignored
1360 pdbi->ptMaxSize.y = sizeStatic.cy + sizeShlFld.cy;
1361 }
1362 if (pdbi->dwMask & DBIM_INTEGRAL)
1363 {
1364 pdbi->ptIntegral.x = 0;
1365 pdbi->ptIntegral.y = 0;
1366 }
1367 if (pdbi->dwMask & DBIM_ACTUAL)
1368 {
1369 SIZE sizeStatic = { 0 };
1370 SIZE sizeShlFld = { 0 };
1371
1372 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, FALSE, (LPARAM) &sizeStatic);
1373 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, FALSE, (LPARAM) &sizeShlFld);
1374 pdbi->ptActual.x = sizeStatic.cx + sizeShlFld.cx;
1375
1376 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeStatic);
1377 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, (LPARAM) &sizeShlFld);
1378 pdbi->ptActual.y = sizeStatic.cy + sizeShlFld.cy;
1379 }
1380 if (pdbi->dwMask & DBIM_TITLE)
1381 wcscpy(pdbi->wszTitle, L"");
1382 if (pdbi->dwMask & DBIM_MODEFLAGS)
1383 pdbi->dwModeFlags = DBIMF_UNDELETEABLE;
1384 if (pdbi->dwMask & DBIM_BKCOLOR)
1385 pdbi->crBkgnd = 0;
1386 return S_OK;
1387 }
1388
1389 /* IDockingWindow */
1390 HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
1391 {
1392 HRESULT hr = S_OK;
1393
1394 if (m_staticToolbar != NULL)
1395 hr = m_staticToolbar->ShowWindow(fShow);
1396 if (FAILED(hr))
1397 return hr;
1398 if (m_SFToolbar != NULL)
1399 hr = m_SFToolbar->ShowWindow(fShow);
1400 if (FAILED(hr))
1401 return hr;
1402
1403 if (fShow)
1404 return _CallCB(SMC_INITMENU, 0, 0);
1405
1406 return S_OK;
1407 }
1408
1409 HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
1410 {
1411 ShowDW(FALSE);
1412
1413 if (m_staticToolbar != NULL)
1414 return m_staticToolbar->Close();
1415
1416 if (m_SFToolbar != NULL)
1417 return m_SFToolbar->Close();
1418
1419 return S_OK;
1420 }
1421 HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
1422 {
1423 UNIMPLEMENTED;
1424 return S_OK;
1425 }
1426
1427 HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
1428 {
1429 UNIMPLEMENTED;
1430 return S_OK;
1431 }
1432
1433 HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
1434 {
1435 UNIMPLEMENTED;
1436 return S_OK;
1437 }
1438
1439 HRESULT STDMETHODCALLTYPE CMenuBand::HasFocusIO()
1440 {
1441 UNIMPLEMENTED;
1442 return S_OK;
1443 }
1444
1445 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateAcceleratorIO(LPMSG lpMsg)
1446 {
1447 UNIMPLEMENTED;
1448 return S_OK;
1449 }
1450
1451 HRESULT STDMETHODCALLTYPE CMenuBand::IsDirty()
1452 {
1453 UNIMPLEMENTED;
1454 return S_OK;
1455 }
1456
1457 HRESULT STDMETHODCALLTYPE CMenuBand::Load(IStream *pStm)
1458 {
1459 UNIMPLEMENTED;
1460 return S_OK;
1461 }
1462
1463 HRESULT STDMETHODCALLTYPE CMenuBand::Save(IStream *pStm, BOOL fClearDirty)
1464 {
1465 UNIMPLEMENTED;
1466 return S_OK;
1467 }
1468
1469 HRESULT STDMETHODCALLTYPE CMenuBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
1470 {
1471 UNIMPLEMENTED;
1472 return S_OK;
1473 }
1474
1475 HRESULT STDMETHODCALLTYPE CMenuBand::GetClassID(CLSID *pClassID)
1476 {
1477 UNIMPLEMENTED;
1478 return S_OK;
1479 }
1480
1481 HRESULT STDMETHODCALLTYPE CMenuBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
1482 {
1483 UNIMPLEMENTED;
1484 return S_OK;
1485 }
1486
1487 HRESULT STDMETHODCALLTYPE CMenuBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1488 {
1489 if (!pguidCmdGroup)
1490 return E_FAIL;
1491
1492 if (IsEqualGUID(*pguidCmdGroup, CLSID_MenuBand))
1493 {
1494 if (nCmdID == 16) // set (big) icon size
1495 {
1496 this->m_useBigIcons = TRUE;
1497 return S_OK;
1498 }
1499 else if (nCmdID == 19) // popup-related
1500 {
1501 return S_FALSE;
1502 }
1503 }
1504
1505 UNIMPLEMENTED;
1506 return S_OK;
1507 }
1508
1509 HRESULT STDMETHODCALLTYPE CMenuBand::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
1510 {
1511 if (IsEqualIID(guidService, SID_SMenuBandChild))
1512 return this->QueryInterface(riid, ppvObject);
1513 WARN("Unknown service requested %s\n", wine_dbgstr_guid(&guidService));
1514 return E_NOINTERFACE;
1515 }
1516
1517 HRESULT STDMETHODCALLTYPE CMenuBand::Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags)
1518 {
1519 UNIMPLEMENTED;
1520 return S_OK;
1521 }
1522
1523 HRESULT STDMETHODCALLTYPE CMenuBand::OnSelect(DWORD dwSelectType)
1524 {
1525 UNIMPLEMENTED;
1526 return S_OK;
1527 }
1528
1529 HRESULT STDMETHODCALLTYPE CMenuBand::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
1530 {
1531 UNIMPLEMENTED;
1532 return S_OK;
1533 }
1534
1535 HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
1536 {
1537 UNIMPLEMENTED;
1538 return S_OK;
1539 }
1540
1541 HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
1542 {
1543 UNIMPLEMENTED;
1544 return S_OK;
1545 }
1546
1547 HRESULT STDMETHODCALLTYPE CMenuBand::IsMenuMessage(MSG *pmsg)
1548 {
1549 //UNIMPLEMENTED;
1550 //return S_OK;
1551 return S_FALSE;
1552 //return E_NOTIMPL;
1553 }
1554
1555 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateMenuMessage(MSG *pmsg, LRESULT *plRet)
1556 {
1557 //UNIMPLEMENTED;
1558 return S_FALSE;
1559 }
1560
1561 HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
1562 {
1563 if (m_SFToolbar == NULL)
1564 {
1565 m_SFToolbar = new CMenuSFToolbar(this);
1566 }
1567
1568 HRESULT hResult = m_SFToolbar->SetShellFolder(psf, pidlFolder, hKey, dwFlags);
1569 if (FAILED(hResult))
1570 return hResult;
1571
1572 if (m_site)
1573 {
1574 HWND hwndParent;
1575
1576 hResult = m_site->GetWindow(&hwndParent);
1577 if (FAILED(hResult))
1578 return hResult;
1579
1580 hResult = m_SFToolbar->CreateToolbar(hwndParent, m_dwFlags);
1581 if (FAILED(hResult))
1582 return hResult;
1583
1584 hResult = m_SFToolbar->FillToolbar();
1585 }
1586
1587 return hResult;
1588 }
1589
1590 HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
1591 {
1592 if (m_SFToolbar)
1593 return m_SFToolbar->GetShellFolder(pdwFlags, ppidl, riid, ppv);
1594 return E_FAIL;
1595 }
1596
1597 HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
1598 {
1599 UNIMPLEMENTED;
1600 return S_OK;
1601 }
1602
1603 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(LPSMDATA psmd)
1604 {
1605 UNIMPLEMENTED;
1606 return S_OK;
1607 }
1608
1609 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
1610 {
1611 UNIMPLEMENTED;
1612 return S_OK;
1613 }
1614
1615 HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
1616 {
1617 *theResult = 0;
1618 if (uMsg == WM_NOTIFY)
1619 {
1620 NMHDR * hdr = (LPNMHDR) lParam;
1621 NMTBCUSTOMDRAW * cdraw;
1622 switch (hdr->code)
1623 {
1624 case NM_CUSTOMDRAW:
1625 cdraw = (LPNMTBCUSTOMDRAW) hdr;
1626 switch (cdraw->nmcd.dwDrawStage)
1627 {
1628 case CDDS_PREPAINT:
1629 *theResult = CDRF_NOTIFYITEMDRAW;
1630 return S_OK;
1631
1632 case CDDS_ITEMPREPAINT:
1633
1634 cdraw->clrBtnFace = GetSysColor(COLOR_MENU);
1635 cdraw->clrBtnHighlight = GetSysColor(COLOR_MENUHILIGHT);
1636
1637 cdraw->clrText = GetSysColor(COLOR_MENUTEXT);
1638 cdraw->clrTextHighlight = GetSysColor(COLOR_HIGHLIGHTTEXT);
1639 cdraw->clrHighlightHotTrack = GetSysColor(COLOR_HIGHLIGHTTEXT);
1640
1641 RECT rc = cdraw->nmcd.rc;
1642 HDC hdc = cdraw->nmcd.hdc;
1643
1644 HBRUSH bgBrush = GetSysColorBrush(COLOR_MENU);
1645 HBRUSH hotBrush = GetSysColorBrush(COLOR_MENUHILIGHT);
1646
1647 switch (cdraw->nmcd.uItemState)
1648 {
1649 case CDIS_HOT:
1650 case CDIS_FOCUS:
1651 FillRect(hdc, &rc, hotBrush);
1652 break;
1653 default:
1654 FillRect(hdc, &rc, bgBrush);
1655 break;
1656 }
1657
1658 *theResult = TBCDRF_NOBACKGROUND | TBCDRF_NOEDGES | TBCDRF_NOETCHEDEFFECT | TBCDRF_HILITEHOTTRACK;
1659 return S_OK;
1660 }
1661 return S_OK;
1662 }
1663 return S_OK;
1664
1665 }
1666 return S_FALSE;
1667 }
1668
1669 HRESULT STDMETHODCALLTYPE CMenuBand::IsWindowOwner(HWND hWnd)
1670 {
1671 HWND hwndStatic = NULL;
1672 HWND hwndShlFld = NULL;
1673 HRESULT hr;
1674
1675 if (m_staticToolbar != NULL)
1676 hr = m_staticToolbar->GetWindow(&hwndStatic);
1677 if (FAILED(hr))
1678 return hr;
1679
1680 if (hWnd == hwndStatic)
1681 return S_OK;
1682
1683 if (m_SFToolbar != NULL)
1684 hr = m_SFToolbar->GetWindow(&hwndShlFld);
1685 if (FAILED(hr))
1686 return hr;
1687
1688 if (hWnd == hwndShlFld)
1689 return S_OK;
1690
1691 return S_FALSE;
1692 }
1693
1694 HRESULT STDMETHODCALLTYPE CMenuBand::GetSubMenu(THIS)
1695 {
1696 UNIMPLEMENTED;
1697 return S_OK;
1698 }
1699
1700 HRESULT STDMETHODCALLTYPE CMenuBand::SetToolbar(THIS)
1701 {
1702 UNIMPLEMENTED;
1703 return S_OK;
1704 }
1705
1706 HRESULT STDMETHODCALLTYPE CMenuBand::SetMinWidth(THIS)
1707 {
1708 UNIMPLEMENTED;
1709 return S_OK;
1710 }
1711
1712 HRESULT STDMETHODCALLTYPE CMenuBand::SetNoBorder(THIS)
1713 {
1714 UNIMPLEMENTED;
1715 return S_OK;
1716 }
1717
1718 HRESULT STDMETHODCALLTYPE CMenuBand::SetTheme(THIS)
1719 {
1720 UNIMPLEMENTED;
1721 return S_OK;
1722 }
1723
1724 HRESULT STDMETHODCALLTYPE CMenuBand::GetTop(THIS)
1725 {
1726 UNIMPLEMENTED;
1727 return S_OK;
1728 }
1729
1730 HRESULT STDMETHODCALLTYPE CMenuBand::GetBottom(THIS)
1731 {
1732 UNIMPLEMENTED;
1733 return S_OK;
1734 }
1735
1736 HRESULT STDMETHODCALLTYPE CMenuBand::GetTracked(THIS)
1737 {
1738 UNIMPLEMENTED;
1739 return S_OK;
1740 }
1741
1742 HRESULT STDMETHODCALLTYPE CMenuBand::GetParentSite(THIS)
1743 {
1744 UNIMPLEMENTED;
1745 return S_OK;
1746 }
1747
1748 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(THIS)
1749 {
1750 UNIMPLEMENTED;
1751 return S_OK;
1752 }
1753
1754 HRESULT STDMETHODCALLTYPE CMenuBand::DoDefaultAction(THIS)
1755 {
1756 UNIMPLEMENTED;
1757 return S_OK;
1758 }
1759
1760 HRESULT STDMETHODCALLTYPE CMenuBand::IsEmpty(THIS)
1761 {
1762 UNIMPLEMENTED;
1763 return S_OK;
1764 }
1765
1766 HRESULT CMenuBand::CallCBWithId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam)
1767 {
1768 if (!m_psmc)
1769 return S_FALSE;
1770
1771 HWND hwnd;
1772 GetWindow(&hwnd);
1773
1774 SMDATA smData = { 0 };
1775 smData.punk = (IShellMenu2*)this;
1776 smData.uId = Id;
1777 smData.uIdParent = m_uId;
1778 smData.uIdAncestor = m_uIdAncestor;
1779 smData.hwnd = hwnd;
1780 if (m_staticToolbar)
1781 {
1782 smData.hmenu = m_hmenu;
1783 }
1784 smData.pvUserData = NULL;
1785 if (m_SFToolbar)
1786 m_SFToolbar->GetShellFolder(NULL, &smData.pidlFolder, IID_PPV_ARG(IShellFolder, &smData.psf));
1787 HRESULT hr = m_psmc->CallbackSM(&smData, uMsg, wParam, lParam);
1788 ILFree(smData.pidlFolder);
1789 if (smData.psf)
1790 smData.psf->Release();
1791 return hr;
1792 }
1793
1794 HRESULT CMenuBand::_CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
1795 {
1796 if (!m_psmc)
1797 return S_FALSE;
1798
1799 HWND hwnd;
1800 GetWindow(&hwnd);
1801
1802 SMDATA smData = { 0 };
1803 smData.punk = (IShellMenu2*)this;
1804 smData.uIdParent = m_uId;
1805 smData.uIdAncestor = m_uIdAncestor;
1806 smData.hwnd = hwnd;
1807 if (m_staticToolbar)
1808 {
1809 smData.hmenu = m_hmenu;
1810 }
1811 smData.pvUserData = NULL;
1812 if (m_SFToolbar)
1813 m_SFToolbar->GetShellFolder(NULL, &smData.pidlFolder, IID_PPV_ARG(IShellFolder, &smData.psf));
1814 HRESULT hr = m_psmc->CallbackSM(&smData, uMsg, wParam, lParam);
1815 ILFree(smData.pidlFolder);
1816 if (smData.psf)
1817 smData.psf->Release();
1818 return hr;
1819 }
1820
1821 #endif