ReactOS  0.4.15-dev-3217-gc6d1646
CNewMenu.h
Go to the documentation of this file.
1 /*
2  * provides new shell item service
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 _SHV_ITEM_NEW_H_
24 #define _SHV_ITEM_NEW_H_
25 
26 const WCHAR ShellNewKey[] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Discardable\\PostSetup\\ShellNew";
27 
28 class CNewMenu :
29  public CComCoClass<CNewMenu, &CLSID_NewMenu>,
30  public CComObjectRootEx<CComMultiThreadModelNoCS>,
31  public IObjectWithSite,
32  public IContextMenu3,
33  public IShellExtInit
34 {
35 private:
37  {
43  };
44 
46  {
54  };
55 
58  SHELLNEW_ITEM *m_pLinkItem; // Points to the link handler item in the m_pItems list.
59  CComPtr<IUnknown> m_pSite;
63 
64  SHELLNEW_ITEM *LoadItem(LPCWSTR pwszExt);
65  void UnloadItem(SHELLNEW_ITEM *pItem);
66  void UnloadAllItems();
67  BOOL CacheItems();
70  UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu);
74  HRESULT SelectNewItem(LONG wEventId, UINT uFlags, LPWSTR pszName, BOOL bRename);
77  DWORD cchNameMax, LPCWSTR wszPath);
78 
79 public:
80  CNewMenu();
81  ~CNewMenu();
82 
83  // IObjectWithSite
84  virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
85  virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite);
86 
87  // IContextMenu
88  virtual HRESULT WINAPI QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
90  virtual HRESULT WINAPI GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen);
91 
92  // IContextMenu3
93  virtual HRESULT WINAPI HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
94 
95  // IContextMenu2
97 
98  // IShellExtInit
99  virtual HRESULT STDMETHODCALLTYPE Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID);
100 
103 
105 
108  COM_INTERFACE_ENTRY_IID(IID_IContextMenu3, IContextMenu3)
109  COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2)
110  COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
111  COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit)
112 END_COM_MAP()
113 };
114 
115 #endif /* _SHV_ITEM_NEW_H_ */
static HICON
Definition: imagelist.c:84
#define REFIID
Definition: guiddef.h:118
~CNewMenu()
Definition: CNewMenu.cpp:41
UINT m_idCmdLink
Definition: CNewMenu.h:61
virtual HRESULT STDMETHODCALLTYPE Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
Definition: CNewMenu.cpp:769
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
REFIID riid
Definition: precomp.h:44
HICON m_hIconLink
Definition: CNewMenu.h:62
SHELLNEW_TYPE
Definition: CNewMenu.h:36
UINT m_idCmdFolder
Definition: CNewMenu.h:61
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:612
UINT_PTR WPARAM
Definition: windef.h:207
UINT uFlags
Definition: api.c:59
char * LPSTR
Definition: xmlstorage.h:182
WPARAM wParam
Definition: combotst.c:138
HRESULT NewItemByCommand(SHELLNEW_ITEM *pItem, LPCWSTR wszPath)
Definition: CNewMenu.cpp:475
SHELLNEW_ITEM * LoadItem(LPCWSTR pwszExt)
Definition: CNewMenu.cpp:77
LPITEMIDLIST m_pidlFolder
Definition: CNewMenu.h:56
BOOL LoadCachedItems()
Definition: CNewMenu.cpp:242
SHELLNEW_ITEM * m_pItems
Definition: CNewMenu.h:57
unsigned int BOOL
Definition: ntddk_ex.h:94
CNewMenu()
Definition: CNewMenu.cpp:28
long LONG
Definition: pedump.c:60
virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
Definition: CNewMenu.cpp:665
SHELLNEW_ITEM * m_pLinkItem
Definition: CNewMenu.h:58
LONG_PTR LPARAM
Definition: windef.h:208
virtual HRESULT WINAPI GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen)
Definition: CNewMenu.cpp:686
const WCHAR ShellNewKey[]
Definition: CNewMenu.h:26
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:542
HICON m_hIconFolder
Definition: CNewMenu.h:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define WINAPI
Definition: msvc.h:6
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
const IID IID_IObjectWithSite
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT NewItemByNonCommand(SHELLNEW_ITEM *pItem, LPWSTR wszName, DWORD cchNameMax, LPCWSTR wszPath)
Definition: CNewMenu.cpp:518
UINT m_idCmdFirst
Definition: CNewMenu.h:61
HRESULT CreateNewItem(SHELLNEW_ITEM *pItem, LPCMINVOKECOMMANDINFO lpcmi)
Definition: CNewMenu.cpp:575
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
SHELLNEW_ITEM * FindItemFromIdOffset(UINT IdOffset)
Definition: CNewMenu.cpp:385
static const WCHAR L[]
Definition: oid.c:1250
#define DECLARE_REGISTRY_RESOURCEID(x)
Definition: atlcom.h:606
BOOL CacheItems()
Definition: CNewMenu.cpp:170
virtual HRESULT WINAPI HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CNewMenu.cpp:700
void UnloadAllItems()
Definition: CNewMenu.cpp:62
SHELLNEW_ITEM * pNext
Definition: CNewMenu.h:53
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:562
virtual HRESULT WINAPI QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
Definition: CNewMenu.cpp:625
HRESULT CreateNewFolder(LPCMINVOKECOMMANDINFO lpici)
Definition: CNewMenu.cpp:446
unsigned int UINT
Definition: ndis.h:50
BOOL LoadAllItems()
Definition: CNewMenu.cpp:300
virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite)
Definition: CNewMenu.cpp:618
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:640
unsigned int ULONG
Definition: retypes.h:1
HMENU m_hSubMenu
Definition: CNewMenu.h:60
CComPtr< IUnknown > m_pSite
Definition: CNewMenu.h:59
void UnloadItem(SHELLNEW_ITEM *pItem)
Definition: CNewMenu.cpp:49
virtual HRESULT WINAPI HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
Definition: CNewMenu.cpp:707
#define END_COM_MAP()
Definition: atlcom.h:553
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
#define IDR_NEWMENU
Definition: shresdef.h:858
virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite)
Definition: CNewMenu.cpp:612
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
BYTE * PBYTE
Definition: pedump.c:66
LPARAM lParam
Definition: combotst.c:139
UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu)
Definition: CNewMenu.cpp:317
SHELLNEW_TYPE Type
Definition: CNewMenu.h:47
HRESULT SelectNewItem(LONG wEventId, UINT uFlags, LPWSTR pszName, BOOL bRename)
Definition: CNewMenu.cpp:407