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