1 /* 2 * PROJECT: ReactOS shell32 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: CopyTo and MoveTo implementation 5 * COPYRIGHT: Copyright 2020-2023 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) 6 */ 7 #pragma once 8 9 class CCopyMoveToMenu : 10 public CComObjectRootEx<CComMultiThreadModelNoCS>, 11 public IContextMenu2, 12 public IObjectWithSite, 13 public IShellExtInit 14 { 15 protected: 16 CComPtr<IDataObject> m_pDataObject; 17 CComPtr<IUnknown> m_pSite; 18 19 HRESULT DoRealFileOp(const CIDA *pCIDA, LPCMINVOKECOMMANDINFO lpici, PCUIDLIST_ABSOLUTE pidlDestination); 20 HRESULT DoAction(LPCMINVOKECOMMANDINFO lpici); 21 22 public: 23 CComHeapPtr<ITEMIDLIST> m_pidlFolder; 24 WNDPROC m_fnOldWndProc; 25 BOOL m_bIgnoreTextBoxChange; 26 27 CCopyMoveToMenu(); 28 29 virtual UINT GetCaptionStringID() const = 0; 30 virtual UINT GetButtonStringID() const = 0; 31 virtual UINT GetActionTitleStringID() const = 0; 32 virtual UINT GetFileOp() const = 0; 33 virtual LPCSTR GetVerb() const = 0; 34 STDMETHODIMP QueryContextMenuImpl(BOOL IsCopyOp, HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); 35 36 // IContextMenu 37 STDMETHODIMP GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen) override; 38 STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) override; 39 40 // IContextMenu2 41 STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) override; 42 43 // IShellExtInit 44 STDMETHODIMP Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override; 45 46 // IObjectWithSite 47 STDMETHODIMP SetSite(IUnknown *pUnkSite) override; 48 STDMETHODIMP GetSite(REFIID riid, void **ppvSite) override; 49 }; 50 51 class CCopyToMenu 52 : public CComCoClass<CCopyToMenu, &CLSID_CopyToMenu> 53 , public CCopyMoveToMenu 54 { 55 public: 56 CComHeapPtr<ITEMIDLIST> m_pidlFolder; 57 WNDPROC m_fnOldWndProc; 58 BOOL m_bIgnoreTextBoxChange; 59 60 CCopyToMenu() { } 61 62 // IContextMenu 63 STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override; 64 65 DECLARE_REGISTRY_RESOURCEID(IDR_COPYTOMENU) 66 DECLARE_NOT_AGGREGATABLE(CCopyToMenu) 67 68 DECLARE_PROTECT_FINAL_CONSTRUCT() 69 70 BEGIN_COM_MAP(CCopyToMenu) 71 COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2) 72 COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) 73 COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit) 74 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 75 END_COM_MAP() 76 77 UINT GetCaptionStringID() const override { return IDS_COPYITEMS; } 78 UINT GetButtonStringID() const override { return IDS_COPYBUTTON; } 79 UINT GetActionTitleStringID() const override { return IDS_COPYTOTITLE; } 80 UINT GetFileOp() const override { return FO_COPY; } 81 LPCSTR GetVerb() const override { return "copyto"; } 82 }; 83 84 class CMoveToMenu 85 : public CComCoClass<CMoveToMenu, &CLSID_MoveToMenu> 86 , public CCopyMoveToMenu 87 { 88 public: 89 CMoveToMenu() { } 90 91 // IContextMenu 92 STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override; 93 94 DECLARE_REGISTRY_RESOURCEID(IDR_MOVETOMENU) 95 DECLARE_NOT_AGGREGATABLE(CMoveToMenu) 96 97 DECLARE_PROTECT_FINAL_CONSTRUCT() 98 99 BEGIN_COM_MAP(CMoveToMenu) 100 COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2) 101 COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) 102 COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit) 103 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 104 END_COM_MAP() 105 106 UINT GetCaptionStringID() const override { return IDS_MOVEITEMS; } 107 UINT GetButtonStringID() const override { return IDS_MOVEBUTTON; } 108 UINT GetActionTitleStringID() const override { return IDS_MOVETOTITLE; } 109 UINT GetFileOp() const override { return FO_MOVE; } 110 LPCSTR GetVerb() const override { return "moveto"; } 111 }; 112