1 /* 2 * provides new shell item service 3 * 4 * Copyright 2019 Katayama Hirofumi MZ. 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 21 #ifndef _SHV_ITEM_SENDTO_H_ 22 #define _SHV_ITEM_SENDTO_H_ 23 24 extern "C" const GUID CLSID_SendToMenu; 25 26 class CSendToMenu : 27 public CComCoClass<CSendToMenu, &CLSID_SendToMenu>, 28 public CComObjectRootEx<CComMultiThreadModelNoCS>, 29 public IObjectWithSite, 30 public IContextMenu3, 31 public IShellExtInit 32 { 33 private: 34 struct SENDTO_ITEM 35 { 36 LPITEMIDLIST pidlChild; 37 LPWSTR pszText; 38 HICON hIcon; 39 SENDTO_ITEM *pNext; 40 }; 41 42 HMENU m_hSubMenu; 43 SENDTO_ITEM *m_pItems; 44 UINT m_idCmdFirst; 45 46 CComPtr<IUnknown> m_pSite; 47 CComPtr<IShellFolder> m_pDesktop; 48 CComPtr<IShellFolder> m_pSendTo; 49 CComPtr<IDataObject> m_pDataObject; 50 51 BOOL LoadAllItems(HWND hwnd); 52 void UnloadItem(SENDTO_ITEM *pItem); 53 void UnloadAllItems(); 54 55 UINT InsertSendToItems(HMENU hMenu, UINT idFirst, UINT idMenu); 56 57 SENDTO_ITEM *FindItemFromIdOffset(UINT IdOffset); 58 HRESULT DoSendToItem(SENDTO_ITEM *pItem, LPCMINVOKECOMMANDINFO lpici); 59 60 HRESULT DoDrop(IDataObject *pDataObject, IDropTarget *pDropTarget); 61 IShellFolder *GetSpecialFolder(HWND hwnd, int csidl, LPITEMIDLIST *ppidl = NULL); 62 HRESULT GetUIObjectFromPidl(HWND hwnd, LPITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut); 63 64 public: 65 CSendToMenu(); 66 ~CSendToMenu(); 67 68 // IObjectWithSite 69 STDMETHODIMP SetSite(IUnknown *pUnkSite); 70 STDMETHODIMP GetSite(REFIID riid, void **ppvSite); 71 72 // IContextMenu 73 STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); 74 STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi); 75 STDMETHODIMP GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen); 76 77 // IContextMenu3 78 STDMETHODIMP HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult); 79 80 // IContextMenu2 81 STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam); 82 83 // IShellExtInit 84 STDMETHODIMP Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID); 85 86 DECLARE_REGISTRY_RESOURCEID(IDR_SENDTOMENU) 87 DECLARE_NOT_AGGREGATABLE(CSendToMenu) 88 DECLARE_PROTECT_FINAL_CONSTRUCT() 89 90 BEGIN_COM_MAP(CSendToMenu) 91 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 92 COM_INTERFACE_ENTRY_IID(IID_IContextMenu3, IContextMenu3) 93 COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2) 94 COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) 95 COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit) 96 END_COM_MAP() 97 }; 98 99 #endif /* _SHV_ITEM_SENDTO_H_ */ 100