[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 #include <windowsx.h>
23
24 WINE_DEFAULT_DEBUG_CHANNEL(CMenuBand);
25
26 #define WRAP_LOG 0
27
28 #define TBSTYLE_EX_VERTICAL 4
29
30 #define TIMERID_HOTTRACK 1
31 #define SUBCLASS_ID_MENUBAND 1
32
33 extern "C" BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
34
35 class CMenuBand;
36
37 class CMenuToolbarBase
38 {
39 public:
40 CMenuToolbarBase(CMenuBand *menuBand);
41 virtual ~CMenuToolbarBase() {}
42
43 HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
44 HRESULT GetWindow(HWND *phwnd);
45 HRESULT ShowWindow(BOOL fShow);
46 HRESULT Close();
47
48 BOOL IsWindowOwner(HWND hwnd) { return m_hwnd && m_hwnd == hwnd; }
49
50 virtual HRESULT FillToolbar() = 0;
51 virtual HRESULT PopupItem(UINT uItem) = 0;
52 virtual HRESULT HasSubMenu(UINT uItem) = 0;
53 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
54 virtual HRESULT OnContextMenu(NMMOUSE * rclick) = 0;
55
56 HRESULT OnHotItemChange(const NMTBHOTITEM * hot);
57
58 HRESULT PopupSubMenu(UINT index, IShellMenu* childShellMenu);
59 HRESULT PopupSubMenu(UINT index, HMENU menu);
60 HRESULT DoContextMenu(IContextMenu* contextMenu);
61
62 static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
63 protected:
64
65 static const UINT WM_USER_SHOWPOPUPMENU = WM_USER + 1;
66
67 LRESULT CALLBACK SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
68
69 CMenuBand *m_menuBand;
70 HWND m_hwnd;
71 DWORD m_dwMenuFlags;
72 INT m_hotItem;
73 WNDPROC m_SubclassOld;
74 };
75
76 class CMenuStaticToolbar : public CMenuToolbarBase
77 {
78 public:
79 CMenuStaticToolbar(CMenuBand *menuBand);
80 virtual ~CMenuStaticToolbar() {}
81
82 HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
83 HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
84
85 virtual HRESULT FillToolbar();
86 virtual HRESULT PopupItem(UINT uItem);
87 virtual HRESULT HasSubMenu(UINT uItem);
88 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
89 virtual HRESULT OnContextMenu(NMMOUSE * rclick);
90
91 private:
92 HMENU m_hmenu;
93 };
94
95 class CMenuSFToolbar : public CMenuToolbarBase
96 {
97 public:
98 CMenuSFToolbar(CMenuBand *menuBand);
99 virtual ~CMenuSFToolbar();
100
101 HRESULT SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
102 HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
103
104 virtual HRESULT FillToolbar();
105 virtual HRESULT PopupItem(UINT uItem);
106 virtual HRESULT HasSubMenu(UINT uItem);
107 virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
108 virtual HRESULT OnContextMenu(NMMOUSE * rclick);
109
110 private:
111 LPITEMIDLIST GetPidlFromId(UINT uItem, INT* pIndex);
112
113 IShellFolder * m_shellFolder;
114 LPCITEMIDLIST m_idList;
115 HKEY m_hKey;
116 };
117
118 class CMenuBand :
119 public CComCoClass<CMenuBand>,
120 public CComObjectRootEx<CComMultiThreadModelNoCS>,
121 public IDeskBand,
122 public IObjectWithSite,
123 public IInputObject,
124 public IPersistStream,
125 public IOleCommandTarget,
126 public IServiceProvider,
127 public IMenuPopup,
128 public IMenuBand,
129 public IShellMenu2,
130 public IWinEventHandler,
131 public IShellMenuAcc
132 {
133 public:
134 CMenuBand();
135 ~CMenuBand();
136
137 private:
138 #if WRAP_LOG
139 IUnknown * m_IUnknown;
140 IDeskBand * m_IDeskBand;
141 IDockingWindow * m_IDockingWindow;
142 IOleWindow * m_IOleWindow;
143 IObjectWithSite * m_IObjectWithSite;
144 IInputObject * m_IInputObject;
145 IPersistStream * m_IPersistStream;
146 IPersist * m_IPersist;
147 IOleCommandTarget * m_IOleCommandTarget;
148 IServiceProvider * m_IServiceProvider;
149 IMenuPopup * m_IMenuPopup;
150 IDeskBar * m_IDeskBar;
151 IMenuBand * m_IMenuBand;
152 IShellMenu2 * m_IShellMenu2;
153 IShellMenu * m_IShellMenu;
154 IWinEventHandler * m_IWinEventHandler;
155 IShellMenuAcc * m_IShellMenuAcc;
156 #else
157 IOleWindow *m_site;
158 IShellMenuCallback *m_psmc;
159
160 CMenuStaticToolbar *m_staticToolbar;
161 CMenuSFToolbar *m_SFToolbar;
162
163 UINT m_uId;
164 UINT m_uIdAncestor;
165 DWORD m_dwFlags;
166 PVOID m_UserData;
167 HMENU m_hmenu;
168 HWND m_menuOwner;
169 #endif
170
171 BOOL m_useBigIcons;
172
173 public:
174
175 // *** IDeskBand methods ***
176 virtual HRESULT STDMETHODCALLTYPE GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi);
177
178 // *** IDockingWindow methods ***
179 virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow);
180 virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved);
181 virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved);
182
183 // *** IOleWindow methods ***
184 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
185 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
186
187 // *** IObjectWithSite methods ***
188 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
189 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite);
190
191 // *** IInputObject methods ***
192 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
193 virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
194 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
195
196 // *** IPersistStream methods ***
197 virtual HRESULT STDMETHODCALLTYPE IsDirty();
198 virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
199 virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
200 virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
201
202 // *** IPersist methods ***
203 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
204
205 // *** IOleCommandTarget methods ***
206 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText);
207 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
208
209 // *** IServiceProvider methods ***
210 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
211
212 // *** IMenuPopup methods ***
213 virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags);
214 virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType);
215 virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet);
216
217 // *** IDeskBar methods ***
218 virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient);
219 virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
220 virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(RECT *prc);
221
222 // *** IMenuBand methods ***
223 virtual HRESULT STDMETHODCALLTYPE IsMenuMessage(MSG *pmsg);
224 virtual HRESULT STDMETHODCALLTYPE TranslateMenuMessage(MSG *pmsg, LRESULT *plRet);
225
226 // *** IShellMenu methods ***
227 virtual HRESULT STDMETHODCALLTYPE Initialize(IShellMenuCallback *psmc, UINT uId, UINT uIdAncestor, DWORD dwFlags);
228 virtual HRESULT STDMETHODCALLTYPE GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags);
229 virtual HRESULT STDMETHODCALLTYPE SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags);
230 virtual HRESULT STDMETHODCALLTYPE GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv);
231 virtual HRESULT STDMETHODCALLTYPE SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
232 virtual HRESULT STDMETHODCALLTYPE GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
233 virtual HRESULT STDMETHODCALLTYPE InvalidateItem(LPSMDATA psmd, DWORD dwFlags);
234 virtual HRESULT STDMETHODCALLTYPE GetState(LPSMDATA psmd);
235 virtual HRESULT STDMETHODCALLTYPE SetMenuToolbar(IUnknown *punk, DWORD dwFlags);
236
237 // *** IWinEventHandler methods ***
238 virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult);
239 virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
240
241 // *** IShellMenu2 methods ***
242 virtual HRESULT STDMETHODCALLTYPE GetSubMenu(THIS);
243 virtual HRESULT STDMETHODCALLTYPE SetToolbar(THIS);
244 virtual HRESULT STDMETHODCALLTYPE SetMinWidth(THIS);
245 virtual HRESULT STDMETHODCALLTYPE SetNoBorder(THIS);
246 virtual HRESULT STDMETHODCALLTYPE SetTheme(THIS);
247
248 // *** IShellMenuAcc methods ***
249 virtual HRESULT STDMETHODCALLTYPE GetTop(THIS);
250 virtual HRESULT STDMETHODCALLTYPE GetBottom(THIS);
251 virtual HRESULT STDMETHODCALLTYPE GetTracked(THIS);
252 virtual HRESULT STDMETHODCALLTYPE GetParentSite(THIS);
253 virtual HRESULT STDMETHODCALLTYPE GetState(THIS);
254 virtual HRESULT STDMETHODCALLTYPE DoDefaultAction(THIS);
255 virtual HRESULT STDMETHODCALLTYPE IsEmpty(THIS);
256
257 HRESULT CallCBWithId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam);
258 HRESULT CallCBWithPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam);
259 HRESULT TrackPopup(HMENU popup, INT x, INT y, RECT& rc);
260
261 BOOL UseBigIcons() {
262 return m_useBigIcons;
263 }
264
265 DECLARE_NOT_AGGREGATABLE(CMenuBand)
266 DECLARE_PROTECT_FINAL_CONSTRUCT()
267
268 BEGIN_COM_MAP(CMenuBand)
269 COM_INTERFACE_ENTRY_IID(IID_IDeskBar, IMenuPopup)
270 COM_INTERFACE_ENTRY_IID(IID_IShellMenu, IShellMenu)
271 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
272 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IDeskBand)
273 COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
274 COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
275 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
276 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
277 COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
278 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersistStream)
279 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
280 COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
281 COM_INTERFACE_ENTRY_IID(IID_IMenuBand, IMenuBand)
282 COM_INTERFACE_ENTRY_IID(IID_IShellMenu2, IShellMenu2)
283 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
284 COM_INTERFACE_ENTRY_IID(IID_IShellMenuAcc, IShellMenuAcc)
285 END_COM_MAP()
286
287 private:
288 HRESULT _CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam, UINT id = 0, LPITEMIDLIST pidl = NULL);
289 };
290
291 extern "C"
292 HRESULT CMenuBand_Constructor(REFIID riid, LPVOID *ppv)
293 {
294 *ppv = NULL;
295
296 CMenuBand * site = new CComObject<CMenuBand>();
297
298 if (!site)
299 return E_OUTOFMEMORY;
300
301 HRESULT hr = site->QueryInterface(riid, ppv);
302
303 if (FAILED(hr))
304 site->Release();
305
306 return hr;
307 }
308
309
310 #if WRAP_LOG
311 CMenuBand::CMenuBand()
312 {
313 HRESULT hr;
314 WrapLogOpen();
315
316 hr = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellMenu, &m_IShellMenu));
317 hr = m_IShellMenu->QueryInterface(IID_PPV_ARG(IUnknown, &m_IUnknown));
318 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IDeskBand, &m_IDeskBand));
319 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IDockingWindow, &m_IDockingWindow));
320 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IOleWindow, &m_IOleWindow));
321 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IObjectWithSite, &m_IObjectWithSite));
322 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IInputObject, &m_IInputObject));
323 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IPersistStream, &m_IPersistStream));
324 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IPersist, &m_IPersist));
325 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &m_IOleCommandTarget));
326 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IServiceProvider, &m_IServiceProvider));
327 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_IMenuPopup));
328 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IDeskBar, &m_IDeskBar));
329 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IMenuBand, &m_IMenuBand));
330 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IShellMenu2, &m_IShellMenu2));
331 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_IWinEventHandler));
332 hr = m_IUnknown->QueryInterface(IID_PPV_ARG(IShellMenuAcc, &m_IShellMenuAcc));
333 }
334
335 CMenuBand::~CMenuBand()
336 {
337 m_IUnknown->Release();
338 m_IDeskBand->Release();
339 m_IDockingWindow->Release();
340 m_IOleWindow->Release();
341 m_IObjectWithSite->Release();
342 m_IInputObject->Release();
343 m_IPersistStream->Release();
344 m_IPersist->Release();
345 m_IOleCommandTarget->Release();
346 m_IServiceProvider->Release();
347 m_IMenuPopup->Release();
348 m_IDeskBar->Release();
349 m_IMenuBand->Release();
350 m_IShellMenu2->Release();
351 m_IShellMenu->Release();
352 m_IWinEventHandler->Release();
353 m_IShellMenuAcc->Release();
354 WrapLogClose();
355 }
356
357
358 // *** IShellMenu2 methods ***
359 HRESULT STDMETHODCALLTYPE CMenuBand::GetSubMenu(THIS)
360 {
361 WrapLogEnter("CMenuBand<%p>::GetSubMenu()\n", this);
362 HRESULT hr = m_IShellMenu2->GetSubMenu();
363 WrapLogExit("CMenuBand::GetSubMenu() = %08x\n", hr);
364 return hr;
365 }
366
367 HRESULT STDMETHODCALLTYPE CMenuBand::SetToolbar(THIS)
368 {
369 WrapLogEnter("CMenuBand<%p>::SetToolbar()\n", this);
370 HRESULT hr = m_IShellMenu2->SetToolbar();
371 WrapLogExit("CMenuBand::SetToolbar() = %08x\n", hr);
372 return hr;
373 }
374
375 HRESULT STDMETHODCALLTYPE CMenuBand::SetMinWidth(THIS)
376 {
377 WrapLogEnter("CMenuBand<%p>::SetMinWidth()\n", this);
378 HRESULT hr = m_IShellMenu2->SetMinWidth();
379 WrapLogExit("CMenuBand::SetMinWidth() = %08x\n", hr);
380 return hr;
381 }
382
383 HRESULT STDMETHODCALLTYPE CMenuBand::SetNoBorder(THIS)
384 {
385 WrapLogEnter("CMenuBand<%p>::SetNoBorder()\n", this);
386 HRESULT hr = m_IShellMenu2->SetNoBorder();
387 WrapLogExit("CMenuBand::SetNoBorder() = %08x\n", hr);
388 return hr;
389 }
390
391 HRESULT STDMETHODCALLTYPE CMenuBand::SetTheme(THIS)
392 {
393 WrapLogEnter("CMenuBand<%p>::SetTheme()\n", this);
394 HRESULT hr = m_IShellMenu2->SetTheme();
395 WrapLogExit("CMenuBand::SetTheme() = %08x\n", hr);
396 return hr;
397 }
398
399
400 // *** IShellMenuAcc methods ***
401 HRESULT STDMETHODCALLTYPE CMenuBand::GetTop(THIS)
402 {
403 WrapLogEnter("CMenuBand<%p>::GetTop()\n", this);
404 HRESULT hr = m_IShellMenuAcc->GetTop();
405 WrapLogExit("CMenuBand::GetTop() = %08x\n", hr);
406 return hr;
407 }
408
409 HRESULT STDMETHODCALLTYPE CMenuBand::GetBottom(THIS)
410 {
411 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
412 HRESULT hr = m_IShellMenuAcc->GetBottom();
413 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
414 return hr;
415 }
416
417 HRESULT STDMETHODCALLTYPE CMenuBand::GetTracked(THIS)
418 {
419 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
420 HRESULT hr = m_IShellMenuAcc->GetBottom();
421 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
422 return hr;
423 }
424
425 HRESULT STDMETHODCALLTYPE CMenuBand::GetParentSite(THIS)
426 {
427 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
428 HRESULT hr = m_IShellMenuAcc->GetBottom();
429 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
430 return hr;
431 }
432
433 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(THIS)
434 {
435 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
436 HRESULT hr = m_IShellMenuAcc->GetBottom();
437 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
438 return hr;
439 }
440
441 HRESULT STDMETHODCALLTYPE CMenuBand::DoDefaultAction(THIS)
442 {
443 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
444 HRESULT hr = m_IShellMenuAcc->GetBottom();
445 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
446 return hr;
447 }
448
449 HRESULT STDMETHODCALLTYPE CMenuBand::IsEmpty(THIS)
450 {
451 WrapLogEnter("CMenuBand<%p>::GetBottom()\n", this);
452 HRESULT hr = m_IShellMenuAcc->GetBottom();
453 WrapLogExit("CMenuBand::GetBottom() = %08x\n", hr);
454 return hr;
455 }
456
457 // *** IDeskBand methods ***
458 HRESULT STDMETHODCALLTYPE CMenuBand::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi)
459 {
460 WrapLogEnter("CMenuBand<%p>::GetBandInfo(DWORD dwBandID=%d, DWORD dwViewMode=%d, DESKBANDINFO *pdbi=%p)\n", this, dwBandID, dwViewMode, pdbi);
461 HRESULT hr = m_IDeskBand->GetBandInfo(dwBandID, dwViewMode, pdbi);
462 WrapLogExit("CMenuBand::GetBandInfo() = %08x\n", hr);
463 return hr;
464 }
465
466 // *** IDockingWindow methods ***
467 HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
468 {
469 WrapLogEnter("CMenuBand<%p>::ShowDW(BOOL fShow=%d)\n", this, fShow);
470 HRESULT hr = m_IDockingWindow->ShowDW(fShow);
471 WrapLogExit("CMenuBand::ShowDW() = %08x\n", hr);
472 return hr;
473 }
474
475 HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
476 {
477 WrapLogEnter("CMenuBand<%p>::CloseDW(DWORD dwReserved=%d)\n", this, dwReserved);
478 HRESULT hr = m_IDockingWindow->CloseDW(dwReserved);
479 WrapLogExit("CMenuBand::CloseDW() = %08x\n", hr);
480 return hr;
481 }
482
483 HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
484 {
485 WrapLogEnter("CMenuBand<%p>::ResizeBorderDW(LPCRECT prcBorder=%p, IUnknown *punkToolbarSite=%p, BOOL fReserved=%d)\n", this, prcBorder, punkToolbarSite, fReserved);
486 if (prcBorder) WrapLogMsg("*prcBorder=%s\n", Wrap(*prcBorder));
487 HRESULT hr = m_IDockingWindow->ResizeBorderDW(prcBorder, punkToolbarSite, fReserved);
488 if (prcBorder) WrapLogMsg("*prcBorder=%s\n", Wrap(*prcBorder));
489 WrapLogExit("CMenuBand::ResizeBorderDW() = %08x\n", hr);
490 return hr;
491 }
492
493 // *** IOleWindow methods ***
494 HRESULT STDMETHODCALLTYPE CMenuBand::GetWindow(HWND *phwnd)
495 {
496 WrapLogEnter("CMenuBand<%p>::GetWindow(HWND *phwnd=%p)\n", this, phwnd);
497 HRESULT hr = m_IOleWindow->GetWindow(phwnd);
498 if (phwnd) WrapLogMsg("*phwnd=%p\n", *phwnd);
499 WrapLogExit("CMenuBand::GetWindow() = %08x\n", hr);
500 return hr;
501 }
502 HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
503 {
504 WrapLogEnter("CMenuBand<%p>::ContextSensitiveHelp(BOOL fEnterMode=%d)\n", this, fEnterMode);
505 HRESULT hr = m_IOleWindow->ContextSensitiveHelp(fEnterMode);
506 WrapLogExit("CMenuBand::ContextSensitiveHelp() = %08x\n", hr);
507 return hr;
508 }
509
510 // *** IWinEventHandler methods ***
511 HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
512 {
513 //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);
514 HRESULT hr = m_IWinEventHandler->OnWinEvent(hWnd, uMsg, wParam, lParam, theResult);
515 //WrapLogExit("CMenuBand::OnWinEvent() = %08x\n", hr);
516 return hr;
517 }
518
519 HRESULT STDMETHODCALLTYPE CMenuBand::IsWindowOwner(HWND hWnd)
520 {
521 //WrapLogEnter("CMenuBand<%p>::IsWindowOwner(HWND hWnd=%08x)\n", this, hWnd);
522 HRESULT hr = m_IWinEventHandler->IsWindowOwner(hWnd);
523 //WrapLogExit("CMenuBand::IsWindowOwner() = %08x\n", hr);
524 return hr;
525 }
526
527 // *** IObjectWithSite methods ***
528 HRESULT STDMETHODCALLTYPE CMenuBand::SetSite(IUnknown *pUnkSite)
529 {
530 WrapLogEnter("CMenuBand<%p>::SetSite(IUnknown *pUnkSite=%p)\n", this, pUnkSite);
531 HRESULT hr = m_IObjectWithSite->SetSite(pUnkSite);
532 WrapLogExit("CMenuBand::SetSite() = %08x\n", hr);
533 return hr;
534 }
535
536 HRESULT STDMETHODCALLTYPE CMenuBand::GetSite(REFIID riid, PVOID *ppvSite)
537 {
538 WrapLogEnter("CMenuBand<%p>::GetSite(REFIID riid=%s, PVOID *ppvSite=%p)\n", this, Wrap(riid), ppvSite);
539 HRESULT hr = m_IObjectWithSite->GetSite(riid, ppvSite);
540 if (ppvSite) WrapLogMsg("*ppvSite=%p\n", *ppvSite);
541 WrapLogExit("CMenuBand::GetSite() = %08x\n", hr);
542 return hr;
543 }
544
545 // *** IInputObject methods ***
546 HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
547 {
548 WrapLogEnter("CMenuBand<%p>::UIActivateIO(BOOL fActivate=%d, LPMSG lpMsg=%p)\n", this, fActivate, lpMsg);
549 HRESULT hr = m_IInputObject->UIActivateIO(fActivate, lpMsg);
550 WrapLogExit("CMenuBand::UIActivateIO() = %08x\n", hr);
551 return hr;
552 }
553
554 HRESULT STDMETHODCALLTYPE CMenuBand::HasFocusIO()
555 {
556 WrapLogEnter("CMenuBand<%p>::HasFocusIO()\n", this);
557 HRESULT hr = m_IInputObject->HasFocusIO();
558 WrapLogExit("CMenuBand::HasFocusIO() = %08x\n", hr);
559 return hr;
560 }
561
562 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateAcceleratorIO(LPMSG lpMsg)
563 {
564 WrapLogEnter("CMenuBand<%p>::TranslateAcceleratorIO(LPMSG lpMsg=%p)\n", this, lpMsg);
565 if (lpMsg) WrapLogMsg("*lpMsg=%s\n", Wrap(*lpMsg));
566 HRESULT hr = m_IInputObject->TranslateAcceleratorIO(lpMsg);
567 WrapLogExit("CMenuBand::TranslateAcceleratorIO() = %08x\n", hr);
568 return hr;
569 }
570
571 // *** IPersistStream methods ***
572 HRESULT STDMETHODCALLTYPE CMenuBand::IsDirty()
573 {
574 WrapLogEnter("CMenuBand<%p>::IsDirty()\n", this);
575 HRESULT hr = m_IPersistStream->IsDirty();
576 WrapLogExit("CMenuBand::IsDirty() = %08x\n", hr);
577 return hr;
578 }
579 HRESULT STDMETHODCALLTYPE CMenuBand::Load(IStream *pStm)
580 {
581 WrapLogEnter("CMenuBand<%p>::Load(IStream *pStm=%p)\n", this, pStm);
582 HRESULT hr = m_IPersistStream->Load(pStm);
583 WrapLogExit("CMenuBand::Load() = %08x\n", hr);
584 return hr;
585 }
586 HRESULT STDMETHODCALLTYPE CMenuBand::Save(IStream *pStm, BOOL fClearDirty)
587 {
588 WrapLogEnter("CMenuBand<%p>::Save(IStream *pStm=%p, BOOL fClearDirty=%d)\n", this, pStm, fClearDirty);
589 HRESULT hr = m_IPersistStream->Save(pStm, fClearDirty);
590 WrapLogExit("CMenuBand::Save() = %08x\n", hr);
591 return hr;
592 }
593 HRESULT STDMETHODCALLTYPE CMenuBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
594 {
595 WrapLogEnter("CMenuBand<%p>::GetSizeMax(ULARGE_INTEGER *pcbSize=%p)\n", this, pcbSize);
596 HRESULT hr = m_IPersistStream->GetSizeMax(pcbSize);
597 WrapLogExit("CMenuBand::GetSizeMax() = %08x\n", hr);
598 return hr;
599 }
600
601 // *** IPersist methods ***
602 HRESULT STDMETHODCALLTYPE CMenuBand::GetClassID(CLSID *pClassID)
603 {
604 WrapLogEnter("CMenuBand<%p>::GetClassID(CLSID *pClassID=%p)\n", this, pClassID);
605 HRESULT hr = m_IPersist->GetClassID(pClassID);
606 if (pClassID) WrapLogMsg("*pClassID=%s\n", Wrap(*pClassID));
607 WrapLogExit("CMenuBand::GetClassID() = %08x\n", hr);
608 return hr;
609 }
610
611 // *** IOleCommandTarget methods ***
612 HRESULT STDMETHODCALLTYPE CMenuBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
613 {
614 WrapLogEnter("CMenuBand<%p>::QueryStatus(const GUID *pguidCmdGroup=%p, ULONG cCmds=%u, prgCmds=%p, pCmdText=%p)\n", this, pguidCmdGroup, cCmds, prgCmds, pCmdText);
615 HRESULT hr = m_IOleCommandTarget->QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText);
616 if (pguidCmdGroup) WrapLogMsg("*pguidCmdGroup=%s\n", Wrap(*pguidCmdGroup));
617 WrapLogExit("CMenuBand::QueryStatus() = %08x\n", hr);
618 return hr;
619 }
620
621 HRESULT STDMETHODCALLTYPE CMenuBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
622 {
623 bool b;
624
625 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);
626
627 if (pguidCmdGroup && IsEqualGUID(*pguidCmdGroup, CLSID_MenuBand))
628 {
629 if (nCmdID == 19) // popup
630 {
631 b = true;
632 }
633 }
634
635
636 if (pguidCmdGroup) WrapLogMsg("*pguidCmdGroup=%s\n", Wrap(*pguidCmdGroup));
637 HRESULT hr = m_IOleCommandTarget->Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
638 WrapLogExit("CMenuBand::Exec() = %08x\n", hr);
639 return hr;
640 }
641
642 // *** IServiceProvider methods ***
643 HRESULT STDMETHODCALLTYPE CMenuBand::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
644 {
645 WrapLogEnter("CMenuBand<%p>::QueryService(REFGUID guidService=%s, REFIID riid=%s, void **ppvObject=%p)\n", this, Wrap(guidService), Wrap(riid), ppvObject);
646
647 if (IsEqualIID(guidService, SID_SMenuBandChild))
648 {
649 WrapLogMsg("SID is SID_SMenuBandChild. Using QueryInterface of self instead of wrapped object.\n");
650 HRESULT hr = this->QueryInterface(riid, ppvObject);
651 if (ppvObject) WrapLogMsg("*ppvObject=%p\n", *ppvObject);
652 if (SUCCEEDED(hr))
653 {
654 WrapLogExit("CMenuBand::QueryService() = %08x\n", hr);
655 return hr;
656 }
657 else
658 {
659 WrapLogMsg("QueryInterface on wrapper failed. Handing over to innter object.\n");
660 }
661 }
662 else if (IsEqualIID(guidService, SID_SMenuBandBottom))
663 {
664 WrapLogMsg("SID is SID_SMenuBandBottom. Using QueryInterface of self instead of wrapped object.\n");
665 HRESULT hr = this->QueryInterface(riid, ppvObject);
666 if (ppvObject) WrapLogMsg("*ppvObject=%p\n", *ppvObject);
667 if (SUCCEEDED(hr))
668 {
669 WrapLogExit("CMenuBand::QueryService() = %08x\n", hr);
670 return hr;
671 }
672 else
673 {
674 WrapLogMsg("QueryInterface on wrapper failed. Handing over to innter object.\n");
675 }
676 }
677 else if (IsEqualIID(guidService, SID_SMenuBandBottomSelected))
678 {
679 WrapLogMsg("SID is SID_SMenuBandBottomSelected. Using QueryInterface of self instead of wrapped object.\n");
680 HRESULT hr = this->QueryInterface(riid, ppvObject);
681 if (ppvObject) WrapLogMsg("*ppvObject=%p\n", *ppvObject);
682 if (SUCCEEDED(hr))
683 {
684 WrapLogExit("CMenuBand::QueryService() = %08x\n", hr);
685 return hr;
686 }
687 else
688 {
689 WrapLogMsg("QueryInterface on wrapper failed. Handing over to innter object.\n");
690 }
691 }
692 else
693 {
694 WrapLogMsg("SID not identified.\n");
695 }
696 HRESULT hr = m_IServiceProvider->QueryService(guidService, riid, ppvObject);
697 if (ppvObject) WrapLogMsg("*ppvObject=%p\n", *ppvObject);
698 WrapLogExit("CMenuBand::QueryService() = %08x\n", hr);
699 return hr;
700 }
701
702
703 // *** IMenuPopup methods ***
704 HRESULT STDMETHODCALLTYPE CMenuBand::Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags)
705 {
706 WrapLogEnter("CMenuBand<%p>::Popup(POINTL *ppt=%p, RECTL *prcExclude=%p, MP_POPUPFLAGS dwFlags=%08x)\n", this, ppt, prcExclude, dwFlags);
707 HRESULT hr = m_IMenuPopup->Popup(ppt, prcExclude, dwFlags);
708 WrapLogExit("CMenuBand::Popup() = %08x\n", hr);
709 return hr;
710 }
711
712 HRESULT STDMETHODCALLTYPE CMenuBand::OnSelect(DWORD dwSelectType)
713 {
714 WrapLogEnter("CMenuBand<%p>::OnSelect(DWORD dwSelectType=%08x)\n", this, dwSelectType);
715 HRESULT hr = m_IMenuPopup->OnSelect(dwSelectType);
716 WrapLogExit("CMenuBand::OnSelect() = %08x\n", hr);
717 return hr;
718 }
719
720 HRESULT STDMETHODCALLTYPE CMenuBand::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
721 {
722 WrapLogEnter("CMenuBand<%p>::SetSubMenu(IMenuPopup *pmp=%p, BOOL fSet=%d)\n", this, pmp, fSet);
723 HRESULT hr = m_IMenuPopup->SetSubMenu(pmp, fSet);
724 WrapLogExit("CMenuBand::SetSubMenu() = %08x\n", hr);
725 return hr;
726 }
727
728
729 // *** IDeskBar methods ***
730 HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
731 {
732 WrapLogEnter("CMenuBand<%p>::SetClient(IUnknown *punkClient=%p)\n", this, punkClient);
733 HRESULT hr = m_IDeskBar->SetClient(punkClient);
734 WrapLogExit("CMenuBand::SetClient() = %08x\n", hr);
735 return hr;
736 }
737
738 HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
739 {
740 WrapLogEnter("CMenuBand<%p>::GetClient(IUnknown **ppunkClient=%p)\n", this, ppunkClient);
741 HRESULT hr = m_IDeskBar->GetClient(ppunkClient);
742 if (ppunkClient) WrapLogMsg("*ppunkClient=%p\n", *ppunkClient);
743 WrapLogExit("CMenuBand::GetClient() = %08x\n", hr);
744 return hr;
745 }
746
747 HRESULT STDMETHODCALLTYPE CMenuBand::OnPosRectChangeDB(RECT *prc)
748 {
749 WrapLogEnter("CMenuBand<%p>::OnPosRectChangeDB(RECT *prc=%p)\n", this, prc);
750 HRESULT hr = m_IDeskBar->OnPosRectChangeDB(prc);
751 if (prc) WrapLogMsg("*prc=%s\n", Wrap(*prc));
752 WrapLogExit("CMenuBand::OnPosRectChangeDB() = %08x\n", hr);
753 return hr;
754 }
755
756
757 // *** IMenuBand methods ***
758 HRESULT STDMETHODCALLTYPE CMenuBand::IsMenuMessage(MSG *pmsg)
759 {
760 //WrapLogEnter("CMenuBand<%p>::IsMenuMessage(MSG *pmsg=%p)\n", this, pmsg);
761 HRESULT hr = m_IMenuBand->IsMenuMessage(pmsg);
762 //WrapLogExit("CMenuBand::IsMenuMessage() = %08x\n", hr);
763 return hr;
764 }
765
766 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateMenuMessage(MSG *pmsg, LRESULT *plRet)
767 {
768 //WrapLogEnter("CMenuBand<%p>::TranslateMenuMessage(MSG *pmsg=%p, LRESULT *plRet=%p)\n", this, pmsg, plRet);
769 HRESULT hr = m_IMenuBand->TranslateMenuMessage(pmsg, plRet);
770 //WrapLogExit("CMenuBand::TranslateMenuMessage(*plRet=%d) = %08x\n", *plRet, hr);
771 return hr;
772 }
773
774 // *** IShellMenu methods ***
775 HRESULT STDMETHODCALLTYPE CMenuBand::Initialize(IShellMenuCallback *psmc, UINT uId, UINT uIdAncestor, DWORD dwFlags)
776 {
777 WrapLogEnter("CMenuBand<%p>::Initialize(IShellMenuCallback *psmc=%p, UINT uId=%u, UINT uIdAncestor=%u, DWORD dwFlags=%08x)\n", this, psmc, uId, uIdAncestor, dwFlags);
778 HRESULT hr = m_IShellMenu->Initialize(psmc, uId, uIdAncestor, dwFlags);
779 WrapLogExit("CMenuBand::Initialize() = %08x\n", hr);
780 return hr;
781 }
782
783 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags)
784 {
785 WrapLogEnter("CMenuBand<%p>::GetMenuInfo(IShellMenuCallback **ppsmc=%p, UINT *puId=%p, UINT *puIdAncestor=%p, DWORD *pdwFlags=%p)\n", this, ppsmc, puId, puIdAncestor, pdwFlags);
786 HRESULT hr = m_IShellMenu->GetMenuInfo(ppsmc, puId, puIdAncestor, pdwFlags);
787 if (ppsmc) WrapLogMsg("*ppsmc=%p\n", *ppsmc);
788 if (puId) WrapLogMsg("*puId=%u\n", *puId);
789 if (puIdAncestor) WrapLogMsg("*puIdAncestor=%u\n", *puIdAncestor);
790 if (pdwFlags) WrapLogMsg("*pdwFlags=%08x\n", *pdwFlags);
791 WrapLogExit("CMenuBand::GetMenuInfo() = %08x\n", hr);
792 return hr;
793 }
794
795 HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
796 {
797 WrapLogEnter("CMenuBand<%p>::SetShellFolder(IShellFolder *psf=%p, LPCITEMIDLIST pidlFolder=%p, HKEY hKey=%p, DWORD dwFlags=%08x)\n", this, psf, pidlFolder, hKey, dwFlags);
798 HRESULT hr = m_IShellMenu->SetShellFolder(psf, pidlFolder, hKey, dwFlags);
799 WrapLogExit("CMenuBand::SetShellFolder() = %08x\n", hr);
800 return hr;
801 }
802
803 HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
804 {
805 WrapLogEnter("CMenuBand<%p>::GetShellFolder(DWORD *pdwFlags=%p, LPITEMIDLIST *ppidl=%p, REFIID riid=%s, void **ppv=%p)\n", this, pdwFlags, ppidl, Wrap(riid), ppv);
806 HRESULT hr = m_IShellMenu->GetShellFolder(pdwFlags, ppidl, riid, ppv);
807 if (pdwFlags) WrapLogMsg("*pdwFlags=%08x\n", *pdwFlags);
808 if (ppidl) WrapLogMsg("*ppidl=%p\n", *ppidl);
809 if (ppv) WrapLogMsg("*ppv=%p\n", *ppv);
810 WrapLogExit("CMenuBand::GetShellFolder() = %08x\n", hr);
811 return hr;
812 }
813
814 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags)
815 {
816 WrapLogEnter("CMenuBand<%p>::SetMenu(HMENU hmenu=%p, HWND hwnd=%p, DWORD dwFlags=%08x)\n", this, hmenu, hwnd, dwFlags);
817 HRESULT hr = m_IShellMenu->SetMenu(hmenu, hwnd, dwFlags);
818 WrapLogExit("CMenuBand::SetMenu() = %08x\n", hr);
819 return hr;
820 }
821
822 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags)
823 {
824 WrapLogEnter("CMenuBand<%p>::GetMenu(HMENU *phmenu=%p, HWND *phwnd=%p, DWORD *pdwFlags=%p)\n", this, phmenu, phwnd, pdwFlags);
825 HRESULT hr = m_IShellMenu->GetMenu(phmenu, phwnd, pdwFlags);
826 if (phmenu) WrapLogMsg("*phmenu=%p\n", *phmenu);
827 if (phwnd) WrapLogMsg("*phwnd=%p\n", *phwnd);
828 if (pdwFlags) WrapLogMsg("*pdwFlags=%08x\n", *pdwFlags);
829 WrapLogExit("CMenuBand::GetMenu() = %08x\n", hr);
830 return hr;
831 }
832
833 HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
834 {
835 WrapLogEnter("CMenuBand<%p>::InvalidateItem(LPSMDATA psmd=%p, DWORD dwFlags=%08x)\n", this, psmd, dwFlags);
836 HRESULT hr = m_IShellMenu->InvalidateItem(psmd, dwFlags);
837 WrapLogExit("CMenuBand::InvalidateItem() = %08x\n", hr);
838 return hr;
839 }
840
841 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(LPSMDATA psmd)
842 {
843 WrapLogEnter("CMenuBand<%p>::GetState(LPSMDATA psmd=%p)\n", this, psmd);
844 HRESULT hr = m_IShellMenu->GetState(psmd);
845 WrapLogExit("CMenuBand::GetState() = %08x\n", hr);
846 return hr;
847 }
848
849 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
850 {
851 WrapLogEnter("CMenuBand<%p>::SetMenuToolbar(IUnknown *punk=%p, DWORD dwFlags=%08x)\n", this, punk, dwFlags);
852 HRESULT hr = m_IShellMenu->SetMenuToolbar(punk, dwFlags);
853 WrapLogExit("CMenuBand::SetMenuToolbar() = %08x\n", hr);
854 return hr;
855 }
856 #else
857
858 CMenuToolbarBase::CMenuToolbarBase(CMenuBand *menuBand) :
859 m_menuBand(menuBand),
860 m_hwnd(NULL),
861 m_dwMenuFlags(0)
862 {
863 }
864
865 HRESULT CMenuToolbarBase::ShowWindow(BOOL fShow)
866 {
867 ::ShowWindow(m_hwnd, fShow ? SW_SHOW : SW_HIDE);
868
869 HIMAGELIST ilBig, ilSmall;
870 Shell_GetImageLists(&ilBig, &ilSmall);
871
872 if (m_menuBand->UseBigIcons())
873 {
874 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(ilBig));
875 }
876 else
877 {
878 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(ilSmall));
879 }
880
881 return S_OK;
882 }
883
884 HRESULT CMenuToolbarBase::Close()
885 {
886 DestroyWindow(m_hwnd);
887 m_hwnd = NULL;
888 return S_OK;
889 }
890
891 HRESULT CMenuToolbarBase::CreateToolbar(HWND hwndParent, DWORD dwFlags)
892 {
893 LONG tbStyles = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
894 TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | TBSTYLE_REGISTERDROP | TBSTYLE_LIST | TBSTYLE_FLAT | TBSTYLE_CUSTOMERASE |
895 CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_TOP;
896 LONG tbExStyles = TBSTYLE_EX_DOUBLEBUFFER;
897
898 if (dwFlags & SMINIT_VERTICAL)
899 {
900 tbStyles |= CCS_VERT;
901 tbExStyles |= TBSTYLE_EX_VERTICAL | WS_EX_TOOLWINDOW;
902 }
903
904 RECT rc;
905
906 if (!::GetClientRect(hwndParent, &rc) || (rc.left == rc.right) || (rc.top == rc.bottom))
907 {
908 rc.left = 0;
909 rc.top = 0;
910 rc.right = 1;
911 rc.bottom = 1;
912 }
913
914 HWND hwndToolbar = CreateWindowEx(
915 tbExStyles, TOOLBARCLASSNAMEW, NULL,
916 tbStyles, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
917 hwndParent, NULL, _AtlBaseModule.GetModuleInstance(), 0);
918
919 if (hwndToolbar == NULL)
920 return E_FAIL;
921
922 ::SetParent(hwndToolbar, hwndParent);
923
924 m_hwnd = hwndToolbar;
925
926 /* Identify the version of the used Common Controls DLL by sending the size of the TBBUTTON structure */
927 SendMessageW(m_hwnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
928
929 HIMAGELIST ilBig, ilSmall;
930 Shell_GetImageLists(&ilBig, &ilSmall);
931
932 //if (dwFlags & SMINIT_TOPLEVEL)
933 //{
934 // /* Hide the placeholders for the button images */
935 // SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, 0);
936 //}
937 //else
938 if (m_menuBand->UseBigIcons())
939 {
940 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(ilBig));
941 }
942 else
943 {
944 SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(ilSmall));
945 }
946
947 SetWindowLongPtr(m_hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
948 m_SubclassOld = (WNDPROC) SetWindowLongPtr(m_hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(CMenuToolbarBase::s_SubclassProc));
949
950 return S_OK;
951 }
952
953 HRESULT CMenuToolbarBase::GetWindow(HWND *phwnd)
954 {
955 if (!phwnd)
956 return E_FAIL;
957
958 *phwnd = m_hwnd;
959
960 return S_OK;
961 }
962
963 LRESULT CALLBACK CMenuToolbarBase::s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
964 {
965 CMenuToolbarBase * pthis = reinterpret_cast<CMenuToolbarBase *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
966 return pthis->SubclassProc(hWnd, uMsg, wParam, lParam);
967 }
968
969 LRESULT CMenuToolbarBase::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
970 {
971 switch (uMsg)
972 {
973 case WM_TIMER:
974 if (wParam == TIMERID_HOTTRACK)
975 {
976 PopupItem(m_hotItem);
977 KillTimer(hWnd, TIMERID_HOTTRACK);
978 }
979 }
980
981 return m_SubclassOld(hWnd, uMsg, wParam, lParam);
982 }
983
984 HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot)
985 {
986 if (hot->dwFlags & HICF_LEAVING)
987 {
988 KillTimer(m_hwnd, TIMERID_HOTTRACK);
989 }
990 else if (m_hotItem != hot->idNew)
991 {
992 if (HasSubMenu(hot->idNew) == S_OK)
993 {
994 DWORD elapsed;
995 SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0);
996
997 m_hotItem = hot->idNew;
998
999 SetTimer(m_hwnd, TIMERID_HOTTRACK, elapsed, NULL);
1000 }
1001 }
1002
1003 m_menuBand->OnSelect(MPOS_CHILDTRACKING);
1004 return S_OK;
1005 }
1006
1007 HRESULT CMenuToolbarBase::PopupSubMenu(UINT index, IShellMenu* childShellMenu)
1008 {
1009 IBandSite* pBandSite;
1010 IDeskBar* pDeskBar;
1011
1012 HRESULT hr;
1013
1014 RECT rc;
1015 if (!SendMessage(m_hwnd, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc)))
1016 return E_FAIL;
1017
1018 POINT a = { rc.left, rc.top };
1019 POINT b = { rc.right, rc.bottom };
1020
1021 ClientToScreen(m_hwnd, &a);
1022 ClientToScreen(m_hwnd, &b);
1023
1024 POINTL pt = { b.x, b.y };
1025 RECTL rcl = { a.x, a.y, b.x, b.y }; // maybe-TODO: fetch client area of deskbar?
1026
1027
1028 #ifndef USE_BUILTIN_MENUSITE
1029 hr = CoCreateInstance(CLSID_MenuBandSite,
1030 NULL,
1031 CLSCTX_INPROC_SERVER,
1032 IID_PPV_ARG(IBandSite, &pBandSite));
1033 #else
1034 hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite));
1035 #endif
1036 if (FAILED(hr))
1037 return hr;
1038
1039 #ifndef USE_BUILTIN_MENUDESKBAR
1040 hr = CoCreateInstance(CLSID_MenuDeskBar,
1041 NULL,
1042 CLSCTX_INPROC_SERVER,
1043 IID_PPV_ARG(IDeskBar, &pDeskBar));
1044 #else
1045 hr = CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar, &pDeskBar));
1046 #endif
1047 if (FAILED(hr))
1048 return hr;
1049
1050 hr = pDeskBar->SetClient(pBandSite);
1051 if (FAILED(hr))
1052 return hr;
1053
1054 hr = pBandSite->AddBand(childShellMenu);
1055 if (FAILED(hr))
1056 return hr;
1057
1058 CComPtr<IMenuPopup> popup;
1059 hr = pDeskBar->QueryInterface(IID_PPV_ARG(IMenuPopup, &popup));
1060 if (FAILED(hr))
1061 return hr;
1062
1063 popup->Popup(&pt, &rcl, MPPF_TOP | MPPF_RIGHT);
1064
1065 return S_OK;
1066 }
1067
1068 HRESULT CMenuToolbarBase::PopupSubMenu(UINT index, HMENU menu)
1069 {
1070 RECT rc;
1071 if (!SendMessage(m_hwnd, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc)))
1072 return E_FAIL;
1073
1074 POINT a = { rc.left, rc.top };
1075 POINT b = { rc.right, rc.bottom };
1076
1077 ClientToScreen(m_hwnd, &a);
1078 ClientToScreen(m_hwnd, &b);
1079
1080 SetRect(&rc, a.x, a.y, b.x, b.y); // maybe-TODO: fetch client area of deskbar?
1081
1082 HMENU popup = GetSubMenu(menu, index);
1083
1084 m_menuBand->TrackPopup(popup, rc.right, rc.bottom, rc);
1085
1086 return S_OK;
1087 }
1088
1089 HRESULT CMenuToolbarBase::DoContextMenu(IContextMenu* contextMenu)
1090 {
1091 HRESULT hr;
1092 HMENU hPopup = CreatePopupMenu();
1093
1094 if (hPopup == NULL)
1095 return E_FAIL;
1096
1097 hr = contextMenu->QueryContextMenu(hPopup, 0, 0, UINT_MAX, CMF_NORMAL);
1098 if (FAILED(hr))
1099 {
1100 DestroyMenu(hPopup);
1101 return hr;
1102 }
1103
1104 DWORD dwPos = GetMessagePos();
1105 UINT uCommand = ::TrackPopupMenu(hPopup, TPM_RETURNCMD, GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos), 0, m_hwnd, NULL);
1106 if (uCommand == 0)
1107 return S_FALSE;
1108
1109 CMINVOKECOMMANDINFO cmi = { 0 };
1110 cmi.cbSize = sizeof(cmi);
1111 cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1112 cmi.hwnd = m_hwnd;
1113 hr = contextMenu->InvokeCommand(&cmi);
1114
1115 DestroyMenu(hPopup);
1116 return hr;
1117 }
1118
1119 HRESULT CMenuToolbarBase::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
1120 {
1121 m_menuBand->OnSelect(MPOS_EXECUTE);
1122 return S_OK;
1123 }
1124
1125 BOOL
1126 AllocAndGetMenuString(HMENU hMenu, UINT ItemIDByPosition, WCHAR** String)
1127 {
1128 int Length;
1129
1130 Length = GetMenuStringW(hMenu, ItemIDByPosition, NULL, 0, MF_BYPOSITION);
1131
1132 if (!Length)
1133 return FALSE;
1134
1135 /* Also allocate space for the terminating NULL character */
1136 ++Length;
1137 *String = (PWSTR) HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR));
1138
1139 GetMenuStringW(hMenu, ItemIDByPosition, *String, Length, MF_BYPOSITION);
1140
1141 return TRUE;
1142 }
1143
1144 CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand) :
1145 CMenuToolbarBase(menuBand),
1146 m_hmenu(NULL)
1147 {
1148 }
1149
1150 HRESULT CMenuStaticToolbar::GetMenu(
1151 HMENU *phmenu,
1152 HWND *phwnd,
1153 DWORD *pdwFlags)
1154 {
1155 *phmenu = m_hmenu;
1156 *phwnd = NULL;
1157 *pdwFlags = m_dwMenuFlags;
1158
1159 return S_OK;
1160 }
1161
1162 HRESULT CMenuStaticToolbar::SetMenu(
1163 HMENU hmenu,
1164 HWND hwnd,
1165 DWORD dwFlags)
1166 {
1167 m_hmenu = hmenu;
1168 m_dwMenuFlags = dwFlags;
1169
1170 return S_OK;
1171 }
1172
1173 HRESULT CMenuStaticToolbar::FillToolbar()
1174 {
1175 int i;
1176 int ic = GetMenuItemCount(m_hmenu);
1177
1178 for (i = 0; i < ic; i++)
1179 {
1180 MENUITEMINFOW info;
1181 TBBUTTON tbb = { 0 };
1182 PWSTR MenuString = NULL;
1183
1184 tbb.fsState = TBSTATE_ENABLED;
1185 tbb.fsStyle = 0;
1186
1187 info.cbSize = sizeof(info);
1188 info.fMask = MIIM_FTYPE | MIIM_ID;
1189
1190 GetMenuItemInfoW(m_hmenu, i, TRUE, &info);
1191
1192 if (info.fType == MFT_STRING)
1193 {
1194 if (!AllocAndGetMenuString(m_hmenu, i, &MenuString))
1195 return E_OUTOFMEMORY;
1196 if (::GetSubMenu(m_hmenu, i) != NULL)
1197 tbb.fsStyle |= BTNS_DROPDOWN;
1198 tbb.iString = (INT_PTR) MenuString;
1199 tbb.idCommand = info.wID;
1200
1201 SMINFO * sminfo = new SMINFO();
1202 sminfo->dwMask = SMIM_ICON | SMIM_FLAGS;
1203 if (info.wID >= 0 && SUCCEEDED(m_menuBand->CallCBWithId(info.wID, SMC_GETINFO, 0, reinterpret_cast<LPARAM>(sminfo))))
1204 {
1205 tbb.iBitmap = sminfo->iIcon;
1206 tbb.dwData = reinterpret_cast<DWORD_PTR>(sminfo);
1207 // FIXME: remove before deleting the toolbar or it will leak
1208 }
1209 }
1210 else
1211 {
1212 tbb.fsStyle |= BTNS_SEP;
1213 }
1214
1215 SendMessageW(m_hwnd, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb));
1216
1217 if (MenuString)
1218 HeapFree(GetProcessHeap(), 0, MenuString);
1219 }
1220
1221 return S_OK;
1222 }
1223
1224 HRESULT CMenuStaticToolbar::OnContextMenu(NMMOUSE * rclick)
1225 {
1226 CComPtr<IContextMenu> contextMenu;
1227 HRESULT hr = m_menuBand->CallCBWithId(rclick->dwItemSpec, SMC_GETOBJECT, reinterpret_cast<WPARAM>(&IID_IContextMenu), reinterpret_cast<LPARAM>(&contextMenu));
1228 if (hr != S_OK)
1229 return hr;
1230
1231 return DoContextMenu(contextMenu);
1232 }
1233
1234 HRESULT CMenuStaticToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
1235 {
1236 HRESULT hr = m_menuBand->CallCBWithId(wParam, SMC_EXEC, 0, 0);
1237 if (FAILED(hr))
1238 return hr;
1239
1240 return CMenuToolbarBase::OnCommand(wParam, lParam, theResult);
1241 }
1242
1243 HRESULT CMenuStaticToolbar::PopupItem(UINT uItem)
1244 {
1245 TBBUTTONINFO info = { 0 };
1246 info.cbSize = sizeof(TBBUTTONINFO);
1247 info.dwMask = 0;
1248 int index = SendMessage(m_hwnd, TB_GETBUTTONINFO, uItem, reinterpret_cast<LPARAM>(&info));
1249 if (index < 0)
1250 return E_FAIL;
1251
1252 TBBUTTON btn = { 0 };
1253 SendMessage(m_hwnd, TB_GETBUTTON, index, reinterpret_cast<LPARAM>(&btn));
1254
1255 SMINFO * nfo = reinterpret_cast<SMINFO*>(btn.dwData);
1256 if (nfo->dwFlags&SMIF_TRACKPOPUP)
1257 {
1258 return PopupSubMenu(index, m_hmenu);
1259 }
1260 else
1261 {
1262 CComPtr<IShellMenu> shellMenu;
1263 HRESULT hr = m_menuBand->CallCBWithId(uItem, SMC_GETOBJECT, reinterpret_cast<WPARAM>(&IID_IShellMenu), reinterpret_cast<LPARAM>(&shellMenu));
1264 if (FAILED(hr))
1265 return hr;
1266
1267 return PopupSubMenu(index, shellMenu);
1268 }
1269 }
1270
1271 HRESULT CMenuStaticToolbar::HasSubMenu(UINT uItem)
1272 {
1273 TBBUTTONINFO info = { 0 };
1274 info.cbSize = sizeof(TBBUTTONINFO);
1275 info.dwMask = 0;
1276 int index = SendMessage(m_hwnd, TB_GETBUTTONINFO, uItem, reinterpret_cast<LPARAM>(&info));
1277 if (index < 0)
1278 return E_FAIL;
1279 return ::GetSubMenu(m_hmenu, index) ? S_OK : S_FALSE;
1280 }
1281
1282 CMenuSFToolbar::CMenuSFToolbar(CMenuBand * menuBand) :
1283 CMenuToolbarBase(menuBand),
1284 m_shellFolder(NULL)
1285 {
1286 }
1287
1288 CMenuSFToolbar::~CMenuSFToolbar()
1289 {
1290 }
1291
1292 HRESULT CMenuSFToolbar::FillToolbar()
1293 {
1294 HRESULT hr;
1295 TBBUTTON tbb = { 0 };
1296 int i = 0;
1297 PWSTR MenuString;
1298
1299 tbb.fsState = TBSTATE_ENABLED;
1300 tbb.fsStyle = 0;
1301
1302 IEnumIDList * eidl;
1303 m_shellFolder->EnumObjects(m_hwnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &eidl);
1304
1305 LPITEMIDLIST item = static_cast<LPITEMIDLIST>(CoTaskMemAlloc(sizeof(ITEMIDLIST)));
1306 ULONG fetched;
1307 while ((hr = eidl->Next(1, &item, &fetched)) == S_OK)
1308 {
1309 INT index = 0;
1310 INT indexOpen = 0;
1311
1312 CComPtr<IShellItem> psi;
1313 SHCreateShellItem(NULL, m_shellFolder, item, &psi);
1314
1315 hr = psi->GetDisplayName(SIGDN_NORMALDISPLAY, &MenuString);
1316 if (FAILED(hr))
1317 return hr;
1318
1319 index = SHMapPIDLToSystemImageListIndex(m_shellFolder, item, &indexOpen);
1320
1321 SFGAOF attrs;
1322 hr = psi->GetAttributes(SFGAO_FOLDER, &attrs);
1323
1324 if (attrs != 0)
1325 {
1326 tbb.fsStyle |= BTNS_DROPDOWN;
1327 }
1328
1329 tbb.idCommand = i++;
1330 tbb.iString = (INT_PTR) MenuString;
1331 tbb.iBitmap = index;
1332 tbb.dwData = reinterpret_cast<DWORD_PTR>(ILClone(item));
1333 // FIXME: remove before deleting the toolbar or it will leak
1334
1335 SendMessageW(m_hwnd, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb));
1336 HeapFree(GetProcessHeap(), 0, MenuString);
1337
1338 }
1339 CoTaskMemFree(item);
1340
1341 return hr;
1342 }
1343
1344 HRESULT CMenuSFToolbar::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
1345 {
1346 m_shellFolder = psf;
1347 m_idList = pidlFolder;
1348 m_hKey = hKey;
1349 m_dwMenuFlags = dwFlags;
1350 return S_OK;
1351 }
1352
1353 HRESULT CMenuSFToolbar::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
1354 {
1355 HRESULT hr;
1356
1357 hr = m_shellFolder->QueryInterface(riid, ppv);
1358 if (FAILED(hr))
1359 return hr;
1360
1361 if (pdwFlags)
1362 *pdwFlags = m_dwMenuFlags;
1363
1364 if (ppidl)
1365 {
1366 LPITEMIDLIST pidl = NULL;
1367
1368 if (m_idList)
1369 {
1370 pidl = ILClone(m_idList);
1371 if (!pidl)
1372 {
1373 (*(IUnknown**) ppv)->Release();
1374 return E_FAIL;
1375 }
1376 }
1377
1378 *ppidl = pidl;
1379 }
1380
1381 return hr;
1382 }
1383
1384 LPITEMIDLIST CMenuSFToolbar::GetPidlFromId(UINT uItem, INT* pIndex)
1385 {
1386 TBBUTTONINFO info = { 0 };
1387 info.cbSize = sizeof(TBBUTTONINFO);
1388 info.dwMask = 0;
1389 int index = SendMessage(m_hwnd, TB_GETBUTTONINFO, uItem, reinterpret_cast<LPARAM>(&info));
1390 if (index < 0)
1391 return NULL;
1392
1393 if (pIndex)
1394 *pIndex = index;
1395
1396 TBBUTTON btn = { 0 };
1397 if (!SendMessage(m_hwnd, TB_GETBUTTON, index, reinterpret_cast<LPARAM>(&btn)))
1398 return NULL;
1399
1400 return reinterpret_cast<LPITEMIDLIST>(btn.dwData);
1401 }
1402
1403 HRESULT CMenuSFToolbar::OnContextMenu(NMMOUSE * rclick)
1404 {
1405 HRESULT hr;
1406 CComPtr<IContextMenu> contextMenu;
1407 LPCITEMIDLIST pidl = reinterpret_cast<LPCITEMIDLIST>(rclick->dwItemData);
1408
1409 hr = m_shellFolder->GetUIObjectOf(m_hwnd, 1, &pidl, IID_IContextMenu, NULL, reinterpret_cast<VOID **>(&contextMenu));
1410 if (hr != S_OK)
1411 return hr;
1412
1413 return DoContextMenu(contextMenu);
1414 }
1415
1416 HRESULT CMenuSFToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
1417 {
1418 return m_menuBand->CallCBWithPidl(GetPidlFromId(wParam, NULL), SMC_SFEXEC, 0, 0);
1419 }
1420
1421 HRESULT CMenuSFToolbar::PopupItem(UINT uItem)
1422 {
1423 HRESULT hr;
1424 UINT uId;
1425 UINT uIdAncestor;
1426 DWORD flags;
1427 int index;
1428 CComPtr<IShellMenuCallback> psmc;
1429 CComPtr<IShellMenu> shellMenu;
1430
1431 LPITEMIDLIST pidl = GetPidlFromId(uItem, &index);
1432
1433 if (!pidl)
1434 return E_FAIL;
1435
1436 #ifndef USE_BUILTIN_MENUBAND
1437 hr = CoCreateInstance(CLSID_MenuBand,
1438 NULL,
1439 CLSCTX_INPROC_SERVER,
1440 IID_PPV_ARG(IShellMenu, &pShellMenu));
1441 #else
1442 hr = CMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &shellMenu));
1443 #endif
1444 if (FAILED(hr))
1445 return hr;
1446
1447 m_menuBand->GetMenuInfo(&psmc, &uId, &uIdAncestor, &flags);
1448
1449 // FIXME: not sure waht to use as uId/uIdAncestor here
1450 hr = shellMenu->Initialize(psmc, 0, uId, SMINIT_VERTICAL);
1451 if (FAILED(hr))
1452 return hr;
1453
1454 CComPtr<IShellFolder> childFolder;
1455 hr = m_shellFolder->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &childFolder));
1456 if (FAILED(hr))
1457 return hr;
1458
1459 hr = shellMenu->SetShellFolder(childFolder, NULL, NULL, 0);
1460 if (FAILED(hr))
1461 return hr;
1462
1463 return PopupSubMenu(index, shellMenu);
1464 }
1465
1466 HRESULT CMenuSFToolbar::HasSubMenu(UINT uItem)
1467 {
1468 HRESULT hr;
1469 CComPtr<IShellItem> psi;
1470 SHCreateShellItem(NULL, m_shellFolder, GetPidlFromId(uItem, NULL), &psi);
1471
1472 SFGAOF attrs;
1473 hr = psi->GetAttributes(SFGAO_FOLDER, &attrs);
1474
1475 return (attrs != 0) ? S_OK : S_FALSE;
1476 }
1477
1478 CMenuBand::CMenuBand() :
1479 m_site(NULL),
1480 m_psmc(NULL),
1481 m_staticToolbar(NULL),
1482 m_SFToolbar(NULL),
1483 m_useBigIcons(FALSE)
1484 {
1485 }
1486
1487 CMenuBand::~CMenuBand()
1488 {
1489 if (m_site)
1490 m_site->Release();
1491
1492 if (m_psmc)
1493 m_psmc->Release();
1494
1495 if (m_staticToolbar)
1496 delete m_staticToolbar;
1497
1498 if (m_SFToolbar)
1499 delete m_SFToolbar;
1500 }
1501
1502 HRESULT STDMETHODCALLTYPE CMenuBand::Initialize(
1503 IShellMenuCallback *psmc,
1504 UINT uId,
1505 UINT uIdAncestor,
1506 DWORD dwFlags)
1507 {
1508 if (m_psmc)
1509 m_psmc->Release();
1510
1511 m_psmc = psmc;
1512 m_uId = uId;
1513 m_uIdAncestor = uIdAncestor;
1514 m_dwFlags = dwFlags;
1515
1516 if (m_psmc)
1517 {
1518 m_psmc->AddRef();
1519
1520 _CallCB(SMC_CREATE, 0, reinterpret_cast<LPARAM>(&m_UserData));
1521 }
1522
1523 return S_OK;
1524 }
1525
1526 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenuInfo(
1527 IShellMenuCallback **ppsmc,
1528 UINT *puId,
1529 UINT *puIdAncestor,
1530 DWORD *pdwFlags)
1531 {
1532 if (!pdwFlags) // maybe?
1533 return E_INVALIDARG;
1534
1535 if (ppsmc)
1536 *ppsmc = m_psmc;
1537
1538 if (puId)
1539 *puId = m_uId;
1540
1541 if (puIdAncestor)
1542 *puIdAncestor = m_uIdAncestor;
1543
1544 *pdwFlags = m_dwFlags;
1545
1546 return S_OK;
1547 }
1548
1549 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenu(
1550 HMENU hmenu,
1551 HWND hwnd,
1552 DWORD dwFlags)
1553 {
1554 if (m_staticToolbar == NULL)
1555 {
1556 m_staticToolbar = new CMenuStaticToolbar(this);
1557 }
1558 m_hmenu = hmenu;
1559 m_menuOwner;
1560
1561 HRESULT hResult = m_staticToolbar->SetMenu(hmenu, hwnd, dwFlags);
1562 if (FAILED(hResult))
1563 return hResult;
1564
1565 if (m_site)
1566 {
1567 HWND hwndParent;
1568
1569 hResult = m_site->GetWindow(&hwndParent);
1570 if (FAILED(hResult))
1571 return hResult;
1572
1573 hResult = m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
1574 if (FAILED(hResult))
1575 return hResult;
1576
1577 hResult = m_staticToolbar->FillToolbar();
1578 }
1579
1580 return hResult;
1581 }
1582
1583 HRESULT STDMETHODCALLTYPE CMenuBand::GetMenu(
1584 HMENU *phmenu,
1585 HWND *phwnd,
1586 DWORD *pdwFlags)
1587 {
1588 if (m_staticToolbar == NULL)
1589 return E_FAIL;
1590
1591 return m_staticToolbar->GetMenu(phmenu, phwnd, pdwFlags);
1592 }
1593
1594 HRESULT STDMETHODCALLTYPE CMenuBand::SetSite(IUnknown *pUnkSite)
1595 {
1596 HWND hwndParent;
1597 HRESULT hResult;
1598
1599 if (m_site != NULL)
1600 m_site->Release();
1601
1602 if (pUnkSite == NULL)
1603 return S_OK;
1604
1605 hwndParent = NULL;
1606 hResult = pUnkSite->QueryInterface(IID_PPV_ARG(IOleWindow, &m_site));
1607 if (SUCCEEDED(hResult))
1608 {
1609 m_site->GetWindow(&hwndParent);
1610 m_site->Release();
1611 }
1612 if (!::IsWindow(hwndParent))
1613 return E_FAIL;
1614
1615 if (m_staticToolbar != NULL)
1616 {
1617 hResult = m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
1618 if (FAILED(hResult))
1619 return hResult;
1620
1621 hResult = m_staticToolbar->FillToolbar();
1622 }
1623
1624 if (m_SFToolbar != NULL)
1625 {
1626 hResult = m_SFToolbar->CreateToolbar(hwndParent, m_dwFlags);
1627 if (FAILED(hResult))
1628 return hResult;
1629
1630 hResult = m_SFToolbar->FillToolbar();
1631 }
1632
1633 return S_OK;
1634 }
1635
1636 HRESULT STDMETHODCALLTYPE CMenuBand::GetSite(REFIID riid, PVOID *ppvSite)
1637 {
1638 if (m_site == NULL)
1639 return E_FAIL;
1640
1641 return m_site->QueryInterface(riid, ppvSite);
1642 }
1643
1644 HRESULT STDMETHODCALLTYPE CMenuBand::GetWindow(
1645 HWND *phwnd)
1646 {
1647 if (m_SFToolbar != NULL)
1648 return m_SFToolbar->GetWindow(phwnd);
1649
1650 if (m_staticToolbar != NULL)
1651 return m_staticToolbar->GetWindow(phwnd);
1652
1653 return E_FAIL;
1654 }
1655
1656 HRESULT STDMETHODCALLTYPE CMenuBand::OnPosRectChangeDB(RECT *prc)
1657 {
1658 SIZE sizeStaticY = { 0 };
1659 SIZE sizeShlFldY = { 0 };
1660 HWND hwndStatic = NULL;
1661 HWND hwndShlFld = NULL;
1662 HRESULT hResult = S_OK;
1663
1664 if (m_staticToolbar != NULL)
1665 hResult = m_staticToolbar->GetWindow(&hwndStatic);
1666 if (FAILED(hResult))
1667 return hResult;
1668
1669 if (m_SFToolbar != NULL)
1670 hResult = m_SFToolbar->GetWindow(&hwndShlFld);
1671 if (FAILED(hResult))
1672 return hResult;
1673
1674 if (hwndStatic == NULL && hwndShlFld == NULL)
1675 return E_FAIL;
1676
1677 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, reinterpret_cast<LPARAM>(&sizeStaticY));
1678 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, reinterpret_cast<LPARAM>(&sizeShlFldY));
1679
1680 int sy = max(prc->bottom - prc->top, sizeStaticY.cy + sizeShlFldY.cy);
1681
1682 if (hwndShlFld)
1683 {
1684 SetWindowPos(hwndShlFld, NULL,
1685 prc->left,
1686 prc->top,
1687 prc->right - prc->left,
1688 sizeShlFldY.cy,
1689 0);
1690 DWORD btnSize = SendMessage(hwndShlFld, TB_GETBUTTONSIZE, 0, 0);
1691 SendMessage(hwndShlFld, TB_SETBUTTONSIZE, 0, MAKELPARAM(prc->right - prc->left, HIWORD(btnSize)));
1692 }
1693 if (hwndStatic)
1694 {
1695 SetWindowPos(hwndStatic, hwndShlFld,
1696 prc->left,
1697 prc->top + sizeShlFldY.cy,
1698 prc->right - prc->left,
1699 sy - sizeShlFldY.cy,
1700 0);
1701 DWORD btnSize = SendMessage(hwndStatic, TB_GETBUTTONSIZE, 0, 0);
1702 SendMessage(hwndStatic, TB_SETBUTTONSIZE, 0, MAKELPARAM(prc->right - prc->left, HIWORD(btnSize)));
1703 }
1704
1705 return S_OK;
1706 }
1707
1708 HRESULT STDMETHODCALLTYPE CMenuBand::GetBandInfo(
1709 DWORD dwBandID,
1710 DWORD dwViewMode,
1711 DESKBANDINFO *pdbi)
1712 {
1713 HWND hwndStatic = NULL;
1714 HWND hwndShlFld = NULL;
1715 HRESULT hResult = S_OK;
1716
1717 if (m_staticToolbar != NULL)
1718 hResult = m_staticToolbar->GetWindow(&hwndStatic);
1719 if (FAILED(hResult))
1720 return hResult;
1721
1722 if (m_SFToolbar != NULL)
1723 hResult = m_SFToolbar->GetWindow(&hwndShlFld);
1724 if (FAILED(hResult))
1725 return hResult;
1726
1727 if (hwndStatic == NULL && hwndShlFld == NULL)
1728 return E_FAIL;
1729
1730 // HACK (?)
1731 if (pdbi->dwMask == 0)
1732 {
1733 pdbi->dwMask = DBIM_MINSIZE | DBIM_MAXSIZE | DBIM_INTEGRAL | DBIM_ACTUAL | DBIM_TITLE | DBIM_MODEFLAGS | DBIM_BKCOLOR;
1734 }
1735
1736 if (pdbi->dwMask & DBIM_MINSIZE)
1737 {
1738 SIZE sizeStatic = { 0 };
1739 SIZE sizeShlFld = { 0 };
1740
1741 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, reinterpret_cast<LPARAM>(&sizeStatic));
1742 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, reinterpret_cast<LPARAM>(&sizeShlFld));
1743
1744 pdbi->ptMinSize.x = 0;
1745 pdbi->ptMinSize.y = sizeStatic.cy + sizeShlFld.cy;
1746 }
1747 if (pdbi->dwMask & DBIM_MAXSIZE)
1748 {
1749 SIZE sizeStatic = { 0 };
1750 SIZE sizeShlFld = { 0 };
1751
1752 if (hwndStatic) SendMessageW(hwndStatic, TB_GETMAXSIZE, 0, reinterpret_cast<LPARAM>(&sizeStatic));
1753 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETMAXSIZE, 0, reinterpret_cast<LPARAM>(&sizeShlFld));
1754
1755 pdbi->ptMaxSize.x = max(sizeStatic.cx, sizeShlFld.cx); // ignored
1756 pdbi->ptMaxSize.y = sizeStatic.cy + sizeShlFld.cy;
1757 }
1758 if (pdbi->dwMask & DBIM_INTEGRAL)
1759 {
1760 pdbi->ptIntegral.x = 0;
1761 pdbi->ptIntegral.y = 0;
1762 }
1763 if (pdbi->dwMask & DBIM_ACTUAL)
1764 {
1765 SIZE sizeStatic = { 0 };
1766 SIZE sizeShlFld = { 0 };
1767
1768 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, FALSE, reinterpret_cast<LPARAM>(&sizeStatic));
1769 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, FALSE, reinterpret_cast<LPARAM>(&sizeShlFld));
1770 pdbi->ptActual.x = max(sizeStatic.cx, sizeShlFld.cx);
1771
1772 if (hwndStatic) SendMessageW(hwndStatic, TB_GETIDEALSIZE, TRUE, reinterpret_cast<LPARAM>(&sizeStatic));
1773 if (hwndShlFld) SendMessageW(hwndShlFld, TB_GETIDEALSIZE, TRUE, reinterpret_cast<LPARAM>(&sizeShlFld));
1774 pdbi->ptActual.y = sizeStatic.cy + sizeShlFld.cy;
1775 }
1776 if (pdbi->dwMask & DBIM_TITLE)
1777 wcscpy(pdbi->wszTitle, L"");
1778 if (pdbi->dwMask & DBIM_MODEFLAGS)
1779 pdbi->dwModeFlags = DBIMF_UNDELETEABLE;
1780 if (pdbi->dwMask & DBIM_BKCOLOR)
1781 pdbi->crBkgnd = 0;
1782 return S_OK;
1783 }
1784
1785 /* IDockingWindow */
1786 HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
1787 {
1788 HRESULT hr = S_OK;
1789
1790 if (m_staticToolbar != NULL)
1791 hr = m_staticToolbar->ShowWindow(fShow);
1792 if (FAILED(hr))
1793 return hr;
1794 if (m_SFToolbar != NULL)
1795 hr = m_SFToolbar->ShowWindow(fShow);
1796 if (FAILED(hr))
1797 return hr;
1798
1799 if (fShow)
1800 return _CallCB(SMC_INITMENU, 0, 0);
1801
1802 return S_OK;
1803 }
1804
1805 HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
1806 {
1807 ShowDW(FALSE);
1808
1809 if (m_staticToolbar != NULL)
1810 return m_staticToolbar->Close();
1811
1812 if (m_SFToolbar != NULL)
1813 return m_SFToolbar->Close();
1814
1815 return S_OK;
1816 }
1817 HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
1818 {
1819 UNIMPLEMENTED;
1820 return S_OK;
1821 }
1822
1823 HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
1824 {
1825 UNIMPLEMENTED;
1826 return S_OK;
1827 }
1828
1829 HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
1830 {
1831 UNIMPLEMENTED;
1832 return S_OK;
1833 }
1834
1835 HRESULT STDMETHODCALLTYPE CMenuBand::HasFocusIO()
1836 {
1837 UNIMPLEMENTED;
1838 return S_OK;
1839 }
1840
1841 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateAcceleratorIO(LPMSG lpMsg)
1842 {
1843 UNIMPLEMENTED;
1844 return S_OK;
1845 }
1846
1847 HRESULT STDMETHODCALLTYPE CMenuBand::IsDirty()
1848 {
1849 UNIMPLEMENTED;
1850 return S_OK;
1851 }
1852
1853 HRESULT STDMETHODCALLTYPE CMenuBand::Load(IStream *pStm)
1854 {
1855 UNIMPLEMENTED;
1856 return S_OK;
1857 }
1858
1859 HRESULT STDMETHODCALLTYPE CMenuBand::Save(IStream *pStm, BOOL fClearDirty)
1860 {
1861 UNIMPLEMENTED;
1862 return S_OK;
1863 }
1864
1865 HRESULT STDMETHODCALLTYPE CMenuBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
1866 {
1867 UNIMPLEMENTED;
1868 return S_OK;
1869 }
1870
1871 HRESULT STDMETHODCALLTYPE CMenuBand::GetClassID(CLSID *pClassID)
1872 {
1873 UNIMPLEMENTED;
1874 return S_OK;
1875 }
1876
1877 HRESULT STDMETHODCALLTYPE CMenuBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
1878 {
1879 UNIMPLEMENTED;
1880 return S_OK;
1881 }
1882
1883 HRESULT STDMETHODCALLTYPE CMenuBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1884 {
1885 if (!pguidCmdGroup)
1886 return E_FAIL;
1887
1888 if (IsEqualGUID(*pguidCmdGroup, CLSID_MenuBand))
1889 {
1890 if (nCmdID == 16) // set (big) icon size
1891 {
1892 this->m_useBigIcons = TRUE;
1893 return S_OK;
1894 }
1895 else if (nCmdID == 19) // popup-related
1896 {
1897 return S_FALSE;
1898 }
1899 }
1900
1901 UNIMPLEMENTED;
1902 return S_OK;
1903 }
1904
1905 HRESULT STDMETHODCALLTYPE CMenuBand::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
1906 {
1907 if (IsEqualIID(guidService, SID_SMenuBandChild) ||
1908 IsEqualIID(guidService, SID_SMenuBandBottom) ||
1909 IsEqualIID(guidService, SID_SMenuBandBottomSelected))
1910 return this->QueryInterface(riid, ppvObject);
1911 WARN("Unknown service requested %s\n", wine_dbgstr_guid(&guidService));
1912 return E_NOINTERFACE;
1913 }
1914
1915 HRESULT STDMETHODCALLTYPE CMenuBand::Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags)
1916 {
1917 UNIMPLEMENTED;
1918 return S_OK;
1919 }
1920
1921 HRESULT STDMETHODCALLTYPE CMenuBand::OnSelect(DWORD dwSelectType)
1922 {
1923 CComPtr<IMenuPopup> pmp;
1924 HRESULT hr = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup, &pmp));
1925 if (FAILED(hr))
1926 return hr;
1927 pmp->OnSelect(dwSelectType);
1928 return S_OK;
1929 }
1930
1931 HRESULT STDMETHODCALLTYPE CMenuBand::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
1932 {
1933 UNIMPLEMENTED;
1934 return S_OK;
1935 }
1936
1937 HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
1938 {
1939 UNIMPLEMENTED;
1940 return S_OK;
1941 }
1942
1943 HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
1944 {
1945 UNIMPLEMENTED;
1946 return S_OK;
1947 }
1948
1949 HRESULT STDMETHODCALLTYPE CMenuBand::IsMenuMessage(MSG *pmsg)
1950 {
1951 //UNIMPLEMENTED;
1952 //return S_OK;
1953 return S_FALSE;
1954 //return E_NOTIMPL;
1955 }
1956
1957 HRESULT STDMETHODCALLTYPE CMenuBand::TranslateMenuMessage(MSG *pmsg, LRESULT *plRet)
1958 {
1959 //UNIMPLEMENTED;
1960 return S_FALSE;
1961 }
1962
1963 HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
1964 {
1965 if (m_SFToolbar == NULL)
1966 {
1967 m_SFToolbar = new CMenuSFToolbar(this);
1968 }
1969
1970 HRESULT hResult = m_SFToolbar->SetShellFolder(psf, pidlFolder, hKey, dwFlags);
1971 if (FAILED(hResult))
1972 return hResult;
1973
1974 if (m_site)
1975 {
1976 HWND hwndParent;
1977
1978 hResult = m_site->GetWindow(&hwndParent);
1979 if (FAILED(hResult))
1980 return hResult;
1981
1982 hResult = m_SFToolbar->CreateToolbar(hwndParent, m_dwFlags);
1983 if (FAILED(hResult))
1984 return hResult;
1985
1986 hResult = m_SFToolbar->FillToolbar();
1987 }
1988
1989 return hResult;
1990 }
1991
1992 HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
1993 {
1994 if (m_SFToolbar)
1995 return m_SFToolbar->GetShellFolder(pdwFlags, ppidl, riid, ppv);
1996 return E_FAIL;
1997 }
1998
1999 HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
2000 {
2001 UNIMPLEMENTED;
2002 return S_OK;
2003 }
2004
2005 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(LPSMDATA psmd)
2006 {
2007 UNIMPLEMENTED;
2008 return S_OK;
2009 }
2010
2011 HRESULT STDMETHODCALLTYPE CMenuBand::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
2012 {
2013 UNIMPLEMENTED;
2014 return S_OK;
2015 }
2016
2017 HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
2018 {
2019 *theResult = 0;
2020 switch (uMsg)
2021 {
2022 case WM_COMMAND:
2023
2024 if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
2025 {
2026 return m_staticToolbar->OnCommand(wParam, lParam, theResult);
2027 }
2028
2029 if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
2030 {
2031 return m_SFToolbar->OnCommand(wParam, lParam, theResult);
2032 }
2033
2034 return S_OK;
2035
2036 case WM_NOTIFY:
2037 NMHDR * hdr = reinterpret_cast<LPNMHDR>(lParam);
2038 NMTBCUSTOMDRAW * cdraw;
2039 NMTBHOTITEM * hot;
2040 NMMOUSE * rclick;
2041 switch (hdr->code)
2042 {
2043 case TBN_HOTITEMCHANGE:
2044 hot = reinterpret_cast<LPNMTBHOTITEM>(hdr);
2045
2046 if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
2047 {
2048 return m_staticToolbar->OnHotItemChange(hot);
2049 }
2050
2051 if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
2052 {
2053 return m_SFToolbar->OnHotItemChange(hot);
2054 }
2055
2056 return S_OK;
2057
2058 case NM_RCLICK:
2059 rclick = reinterpret_cast<LPNMMOUSE>(hdr);
2060
2061 if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
2062 {
2063 return m_staticToolbar->OnContextMenu(rclick);
2064 }
2065
2066 if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
2067 {
2068 return m_SFToolbar->OnContextMenu(rclick);
2069 }
2070
2071 return S_OK;
2072 case NM_CUSTOMDRAW:
2073 cdraw = reinterpret_cast<LPNMTBCUSTOMDRAW>(hdr);
2074 switch (cdraw->nmcd.dwDrawStage)
2075 {
2076 case CDDS_PREPAINT:
2077 *theResult = CDRF_NOTIFYITEMDRAW;
2078 return S_OK;
2079
2080 case CDDS_ITEMPREPAINT:
2081
2082 cdraw->clrBtnFace = GetSysColor(COLOR_MENU);
2083 cdraw->clrBtnHighlight = GetSysColor(COLOR_MENUHILIGHT);
2084
2085 cdraw->clrText = GetSysColor(COLOR_MENUTEXT);
2086 cdraw->clrTextHighlight = GetSysColor(COLOR_HIGHLIGHTTEXT);
2087 cdraw->clrHighlightHotTrack = GetSysColor(COLOR_HIGHLIGHTTEXT);
2088
2089 RECT rc = cdraw->nmcd.rc;
2090 HDC hdc = cdraw->nmcd.hdc;
2091
2092 HBRUSH bgBrush = GetSysColorBrush(COLOR_MENU);
2093 HBRUSH hotBrush = GetSysColorBrush(COLOR_MENUHILIGHT);
2094
2095 switch (cdraw->nmcd.uItemState)
2096 {
2097 case CDIS_HOT:
2098 case CDIS_FOCUS:
2099 FillRect(hdc, &rc, hotBrush);
2100 break;
2101 default:
2102 FillRect(hdc, &rc, bgBrush);
2103 break;
2104 }
2105
2106 *theResult = TBCDRF_NOBACKGROUND | TBCDRF_NOEDGES | TBCDRF_NOETCHEDEFFECT | TBCDRF_HILITEHOTTRACK | TBCDRF_NOOFFSET;
2107 return S_OK;
2108 }
2109 return S_OK;
2110 }
2111 return S_OK;
2112 }
2113
2114 return S_FALSE;
2115 }
2116
2117 HRESULT STDMETHODCALLTYPE CMenuBand::IsWindowOwner(HWND hWnd)
2118 {
2119 if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
2120 return S_OK;
2121
2122 if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
2123 return S_OK;
2124
2125 return S_FALSE;
2126 }
2127
2128 HRESULT STDMETHODCALLTYPE CMenuBand::GetSubMenu(THIS)
2129 {
2130 UNIMPLEMENTED;
2131 return S_OK;
2132 }
2133
2134 HRESULT STDMETHODCALLTYPE CMenuBand::SetToolbar(THIS)
2135 {
2136 UNIMPLEMENTED;
2137 return S_OK;
2138 }
2139
2140 HRESULT STDMETHODCALLTYPE CMenuBand::SetMinWidth(THIS)
2141 {
2142 UNIMPLEMENTED;
2143 return S_OK;
2144 }
2145
2146 HRESULT STDMETHODCALLTYPE CMenuBand::SetNoBorder(THIS)
2147 {
2148 UNIMPLEMENTED;
2149 return S_OK;
2150 }
2151
2152 HRESULT STDMETHODCALLTYPE CMenuBand::SetTheme(THIS)
2153 {
2154 UNIMPLEMENTED;
2155 return S_OK;
2156 }
2157
2158 HRESULT STDMETHODCALLTYPE CMenuBand::GetTop(THIS)
2159 {
2160 UNIMPLEMENTED;
2161 return S_OK;
2162 }
2163
2164 HRESULT STDMETHODCALLTYPE CMenuBand::GetBottom(THIS)
2165 {
2166 UNIMPLEMENTED;
2167 return S_OK;
2168 }
2169
2170 HRESULT STDMETHODCALLTYPE CMenuBand::GetTracked(THIS)
2171 {
2172 UNIMPLEMENTED;
2173 return S_OK;
2174 }
2175
2176 HRESULT STDMETHODCALLTYPE CMenuBand::GetParentSite(THIS)
2177 {
2178 UNIMPLEMENTED;
2179 return S_OK;
2180 }
2181
2182 HRESULT STDMETHODCALLTYPE CMenuBand::GetState(THIS)
2183 {
2184 UNIMPLEMENTED;
2185 return S_OK;
2186 }
2187
2188 HRESULT STDMETHODCALLTYPE CMenuBand::DoDefaultAction(THIS)
2189 {
2190 UNIMPLEMENTED;
2191 return S_OK;
2192 }
2193
2194 HRESULT STDMETHODCALLTYPE CMenuBand::IsEmpty(THIS)
2195 {
2196 UNIMPLEMENTED;
2197 return S_OK;
2198 }
2199
2200 HRESULT CMenuBand::CallCBWithId(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam)
2201 {
2202 return _CallCB(uMsg, wParam, lParam, id);
2203 }
2204
2205 HRESULT CMenuBand::CallCBWithPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam)
2206 {
2207 return _CallCB(uMsg, wParam, lParam, 0, pidl);
2208 }
2209
2210 HRESULT CMenuBand::_CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam, UINT id, LPITEMIDLIST pidl)
2211 {
2212 if (!m_psmc)
2213 return S_FALSE;
2214
2215 HWND hwnd;
2216 GetWindow(&hwnd);
2217
2218 SMDATA smData = { 0 };
2219 smData.punk = static_cast<IShellMenu2*>(this);
2220 smData.uId = id;
2221 smData.uIdParent = m_uId;
2222 smData.uIdAncestor = m_uIdAncestor;
2223 smData.hwnd = hwnd;
2224 smData.pidlItem = pidl;
2225 if (m_staticToolbar)
2226 {
2227 smData.hmenu = m_hmenu;
2228 }
2229 smData.pvUserData = NULL;
2230 if (m_SFToolbar)
2231 m_SFToolbar->GetShellFolder(NULL, &smData.pidlFolder, IID_PPV_ARG(IShellFolder, &smData.psf));
2232 HRESULT hr = m_psmc->CallbackSM(&smData, uMsg, wParam, lParam);
2233 ILFree(smData.pidlFolder);
2234 if (smData.psf)
2235 smData.psf->Release();
2236 return hr;
2237 }
2238
2239 HRESULT CMenuBand::TrackPopup(HMENU popup, INT x, INT y, RECT& rc)
2240 {
2241 ::TrackPopupMenu(popup, 0, x, y, 0, m_menuOwner, &rc);
2242 return S_OK;
2243 }
2244 #endif