xref: /reactos/dll/win32/shell32/COpenWithMenu.h (revision 49b2b1da)
1 /*
2  *  Open With  Context Menu extension
3  *
4  * Copyright 2007 Johannes Anderwald <johannes.anderwald@reactos.org>
5  * Copyright 2009 Andrew Hill
6  * Copyright 2012 Rafal Harabien
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 #ifndef _SHE_OCMENU_H_
24 #define _SHE_OCMENU_H_
25 
26 class COpenWithList;
27 
28 class COpenWithMenu :
29     public CComCoClass<COpenWithMenu, &CLSID_OpenWithMenu>,
30     public CComObjectRootEx<CComMultiThreadModelNoCS>,
31     public IContextMenu2,
32     public IShellExtInit
33 {
34     private:
35         UINT m_idCmdFirst, m_idCmdLast;
36         WCHAR m_wszPath[MAX_PATH];
37         HMENU m_hSubMenu;
38         COpenWithList *m_pAppList;
39 
40         HBITMAP IconToBitmap(HICON hIcon);
41         VOID AddChooseProgramItem();
42         VOID AddApp(PVOID pApp);
43 
44     public:
45         COpenWithMenu();
46         ~COpenWithMenu();
47 
48         // IContextMenu
49         STDMETHOD(QueryContextMenu)(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override;
50         STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpcmi) override;
51         STDMETHOD(GetCommandString)(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen) override;
52 
53         // IContextMenu2
54         STDMETHOD(HandleMenuMsg)(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
55 
56         // IShellExtInit
57         STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override;
58 
59         DECLARE_REGISTRY_RESOURCEID(IDR_OPENWITHMENU)
60         DECLARE_NOT_AGGREGATABLE(COpenWithMenu)
61 
62         DECLARE_PROTECT_FINAL_CONSTRUCT()
63 
64         BEGIN_COM_MAP(COpenWithMenu)
65         COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2)
66         COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
67         COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit)
68         END_COM_MAP()
69 };
70 
71 #endif /* _SHE_OCMENU_H_ */
72