[BROWSEUI] CBandSiteMenu: Use CSimpleArray and CComHeapPtr.
[reactos.git] / dll / win32 / browseui / shellbars / CBandSiteMenu.h
1 /*
2 * Band site menu
3 *
4 * Copyright 2007 Hervé Poussineua
5 * Copyright 2009 Andrew Hill
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #pragma once
23
24 // oddly, this class also responds to QueryInterface for CLSID_BandSiteMenu by returning the vtable at offset 0
25 class CBandSiteMenu :
26 public CComCoClass<CBandSiteMenu, &CLSID_BandSiteMenu>,
27 public CComObjectRootEx<CComMultiThreadModelNoCS>,
28 public IContextMenu3,
29 public IShellService
30 {
31 CComPtr<IBandSite> m_BandSite;
32 CSimpleArray<GUID> m_ComCatGuids;
33 HMENU m_hmenu;
34 CComHeapPtr<ITEMIDLIST> m_DesktopPidl;
35 CComHeapPtr<ITEMIDLIST> m_QLaunchPidl;
36
37 HRESULT _CreateMenuPart();
38 HRESULT _CreateNewISFBand(HWND hwnd, REFIID riid, void** ppv);
39 HRESULT _CreateBuiltInISFBand(UINT uID, REFIID riid, void** ppv);
40 HRESULT _AddISFBandToMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, IUnknown* pBand, DWORD dwBandID, UINT *newMenuId);
41 UINT _GetMenuIdFromISFBand(IUnknown *pBand);
42 UINT _GetMenuIdFromBand(CLSID *BandCLSID);
43 UINT _GetBandIdFromClsid(CLSID* pclsid);
44 UINT _GetBandIdForBuiltinISFBand(UINT uID);
45
46 public:
47 CBandSiteMenu();
48 ~CBandSiteMenu();
49 HRESULT WINAPI FinalConstruct();
50
51 // *** IShellService methods ***
52 virtual HRESULT STDMETHODCALLTYPE SetOwner(IUnknown *);
53
54 // *** IContextMenu methods ***
55 virtual HRESULT STDMETHODCALLTYPE QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
56 virtual HRESULT STDMETHODCALLTYPE InvokeCommand(LPCMINVOKECOMMANDINFO lpici);
57 virtual HRESULT STDMETHODCALLTYPE GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
58
59 // *** IContextMenu2 methods ***
60 virtual HRESULT STDMETHODCALLTYPE HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
61
62 // *** IContextMenu3 methods ***
63 virtual HRESULT STDMETHODCALLTYPE HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
64
65 DECLARE_REGISTRY_RESOURCEID(IDR_BANDSITEMENU)
66 DECLARE_NOT_AGGREGATABLE(CBandSiteMenu)
67
68 DECLARE_PROTECT_FINAL_CONSTRUCT()
69
70 BEGIN_COM_MAP(CBandSiteMenu)
71 COM_INTERFACE_ENTRY_IID(IID_IShellService, IShellService)
72 COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2)
73 COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
74 END_COM_MAP()
75 };