ReactOS 0.4.15-dev-7931-gfd331f1
CCopyMoveToMenu Class Referenceabstract

#include <CCopyMoveToMenu.h>

Inheritance diagram for CCopyMoveToMenu:
Collaboration diagram for CCopyMoveToMenu:

Public Member Functions

 CCopyMoveToMenu ()
 
virtual UINT GetCaptionStringID () const =0
 
virtual UINT GetButtonStringID () const =0
 
virtual UINT GetActionTitleStringID () const =0
 
virtual UINT GetFileOp () const =0
 
virtual LPCSTR GetVerb () const =0
 
STDMETHODIMP GetCommandString (UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen) override
 
STDMETHODIMP InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi) override
 
STDMETHODIMP HandleMenuMsg (UINT uMsg, WPARAM wParam, LPARAM lParam) override
 
STDMETHODIMP Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override
 
STDMETHODIMP SetSite (IUnknown *pUnkSite) override
 
STDMETHODIMP GetSite (REFIID riid, void **ppvSite) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
HRESULT HandleMenuMsg ([in] UINT uMsg, [in] WPARAM wParam, [in] LPARAM lParam)
 
- Public Member Functions inherited from IContextMenu
HRESULT QueryContextMenu ([in] HMENU hmenu, [in] UINT indexMenu, [in] UINT idCmdFirst, [in] UINT idCmdLast, [in] UINT uFlags)
 
HRESULT InvokeCommand ([in] LPCMINVOKECOMMANDINFO lpici)
 
HRESULT GetCommandString ([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- Public Member Functions inherited from IObjectWithSite
HRESULT SetSite ([in] IUnknown *pUnkSite)
 
HRESULT GetSite ([in] REFIID riid, [out, iid_is(riid)] PVOID *ppvSite)
 
HRESULT Initialize ([in] PCIDLIST_ABSOLUTE pidlFolder, [in] IDataObject *pdtobj, [in] HKEY hkeyProgID)
 

Public Attributes

CComHeapPtr< ITEMIDLISTm_pidlFolder
 
WNDPROC m_fnOldWndProc
 
BOOL m_bIgnoreTextBoxChange
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Protected Member Functions

HRESULT DoRealFileOp (LPCMINVOKECOMMANDINFO lpici, PCUIDLIST_ABSOLUTE pidl)
 
HRESULT DoAction (LPCMINVOKECOMMANDINFO lpici)
 

Protected Attributes

UINT m_idCmdFirst
 
UINT m_idCmdLast
 
UINT m_idCmdAction
 
CComPtr< IDataObjectm_pDataObject
 
CComPtr< IUnknownm_pSite
 

Additional Inherited Members

- Public Types inherited from IContextMenu2
typedef IContextMenu2LPCONTEXTMENU2
 
- Public Types inherited from IContextMenu
typedef IContextMenuLPCONTEXTMENU
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IObjectWithSite
typedef IObjectWithSiteLPOBJECTWITHSITE
 
- Public Types inherited from IShellExtInit
typedef IShellExtInitLPSHELLEXTINIT
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Static Public Attributes inherited from IContextMenu
static const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 9 of file CCopyMoveToMenu.h.

Constructor & Destructor Documentation

◆ CCopyMoveToMenu()

CCopyMoveToMenu::CCopyMoveToMenu ( )

Definition at line 12 of file CCopyMoveToMenu.cpp.

12 :
13 m_idCmdFirst(0),
14 m_idCmdLast(0),
15 m_idCmdAction(-1),
18{
19}
WNDPROC m_fnOldWndProc
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117

Member Function Documentation

◆ DoAction()

HRESULT CCopyMoveToMenu::DoAction ( LPCMINVOKECOMMANDINFO  lpici)
protected

Definition at line 226 of file CCopyMoveToMenu.cpp.

227{
228 WCHAR wszPath[MAX_PATH];
229 HRESULT hr = E_FAIL;
230
231 TRACE("(%p)\n", lpici);
232
233 if (!SHGetPathFromIDListW(m_pidlFolder, wszPath))
234 {
235 ERR("SHGetPathFromIDListW failed\n");
236 return hr;
237 }
238
239 CStringW strFileTitle;
240 hr = DoGetFileTitle(strFileTitle, m_pDataObject);
241 if (FAILED(hr))
242 return hr;
243
244 CStringW strTitle;
245 strTitle.Format(GetActionTitleStringID(), static_cast<LPCWSTR>(strFileTitle));
246
247 BROWSEINFOW info = { lpici->hwnd };
248 info.pidlRoot = NULL;
249 info.lpszTitle = strTitle;
252 info.lParam = reinterpret_cast<LPARAM>(this);
254 if (pidl)
255 hr = DoRealFileOp(lpici, pidl);
256
257 return hr;
258}
static HRESULT DoGetFileTitle(CStringW &strTitle, IDataObject *pDataObject)
#define ERR(fmt,...)
Definition: debug.h:110
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
CComHeapPtr< ITEMIDLIST > m_pidlFolder
virtual UINT GetActionTitleStringID() const =0
HRESULT DoRealFileOp(LPCMINVOKECOMMANDINFO lpici, PCUIDLIST_ABSOLUTE pidl)
CComPtr< IDataObject > m_pDataObject
#define E_FAIL
Definition: ddrawi.h:102
#define MAX_PATH
Definition: compat.h:34
#define FAILED(hr)
Definition: intsafe.h:51
static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
Definition: wizard.c:583
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1353
HRESULT hr
Definition: shlfolder.c:183
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1210
#define BIF_USENEWUI
Definition: shlobj.h:1217
#define SHBrowseForFolder
Definition: shlobj.h:1246
#define TRACE(s)
Definition: solgame.cpp:4
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by InvokeCommand().

◆ DoRealFileOp()

HRESULT CCopyMoveToMenu::DoRealFileOp ( LPCMINVOKECOMMANDINFO  lpici,
PCUIDLIST_ABSOLUTE  pidl 
)
protected

Definition at line 125 of file CCopyMoveToMenu.cpp.

126{
127 CDataObjectHIDA pCIDA(m_pDataObject);
128 if (FAILED_UNEXPECTEDLY(pCIDA.hr()))
129 return pCIDA.hr();
130
131 PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(pCIDA);
132 if (!pidlParent)
133 {
134 ERR("HIDA_GetPIDLFolder failed\n");
135 return E_FAIL;
136 }
137
138 CStringW strFiles;
140 for (UINT n = 0; n < pCIDA->cidl; ++n)
141 {
142 PCUIDLIST_RELATIVE pidlRelative = HIDA_GetPIDLItem(pCIDA, n);
143 if (!pidlRelative)
144 continue;
145
146 CComHeapPtr<ITEMIDLIST> pidlCombine(ILCombine(pidlParent, pidlRelative));
147 if (!pidl)
148 return E_FAIL;
149
150 SHGetPathFromIDListW(pidlCombine, szPath);
151
152 if (n > 0)
153 strFiles += L'|';
154 strFiles += szPath;
155 }
156
157 strFiles += L'|'; // double null-terminated
158 strFiles.Replace(L'|', L'\0');
159
160 if (_ILIsDesktop(pidl))
162 else
164 INT cchPath = lstrlenW(szPath);
165 if (cchPath + 1 < MAX_PATH)
166 {
167 szPath[cchPath + 1] = 0; // double null-terminated
168 }
169 else
170 {
171 ERR("Too long path\n");
172 return E_FAIL;
173 }
174
175 SHFILEOPSTRUCTW op = { lpici->hwnd, GetFileOp(), strFiles, szPath };
176 op.fFlags = FOF_ALLOWUNDO;
177 int res = SHFileOperationW(&op);
178 if (res)
179 {
180 ERR("SHFileOperationW failed with 0x%x\n", res);
181 return E_FAIL;
182 }
183 return S_OK;
184}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:886
virtual UINT GetFileOp() const =0
UINT op
Definition: effect.c:236
#define lstrlenW
Definition: compat.h:750
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3092
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
#define S_OK
Definition: intsafe.h:52
LPCWSTR szPath
Definition: env.c:37
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:712
#define FOF_ALLOWUNDO
Definition: shellapi.h:147
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:591
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:586
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1987
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2173
const ITEMIDLIST_ABSOLUTE UNALIGNED * PCUIDLIST_ABSOLUTE
Definition: shtypes.idl:63
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
int32_t INT
Definition: typedefs.h:58

Referenced by DoAction().

◆ GetActionTitleStringID()

virtual UINT CCopyMoveToMenu::GetActionTitleStringID ( ) const
pure virtual

Implemented in CCopyToMenu, and CMoveToMenu.

Referenced by DoAction().

◆ GetButtonStringID()

virtual UINT CCopyMoveToMenu::GetButtonStringID ( ) const
pure virtual

Implemented in CCopyToMenu, and CMoveToMenu.

Referenced by BrowseCallbackProc().

◆ GetCaptionStringID()

virtual UINT CCopyMoveToMenu::GetCaptionStringID ( ) const
pure virtual

Implemented in CCopyToMenu, and CMoveToMenu.

Referenced by BrowseCallbackProc().

◆ GetCommandString()

STDMETHODIMP CCopyMoveToMenu::GetCommandString ( UINT_PTR  idCommand,
UINT  uFlags,
UINT lpReserved,
LPSTR  lpszName,
UINT  uMaxNameLen 
)
override

Implements IContextMenu.

Definition at line 396 of file CCopyMoveToMenu.cpp.

402{
403 FIXME("%p %lu %u %p %p %u\n", this,
404 idCmd, uType, pwReserved, pszName, cchMax);
405
406 return E_NOTIMPL;
407}
UINT cchMax
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetFileOp()

virtual UINT CCopyMoveToMenu::GetFileOp ( ) const
pure virtual

Implemented in CCopyToMenu, and CMoveToMenu.

Referenced by DoRealFileOp().

◆ GetSite()

STDMETHODIMP CCopyMoveToMenu::GetSite ( REFIID  riid,
void **  ppvSite 
)
override

Definition at line 432 of file CCopyMoveToMenu.cpp.

433{
434 if (!m_pSite)
435 return E_FAIL;
436
437 return m_pSite->QueryInterface(riid, ppvSite);
438}
CComPtr< IUnknown > m_pSite
REFIID riid
Definition: atlbase.h:39

◆ GetVerb()

virtual LPCSTR CCopyMoveToMenu::GetVerb ( ) const
pure virtual

Implemented in CCopyToMenu, and CMoveToMenu.

Referenced by InvokeCommand().

◆ HandleMenuMsg()

STDMETHODIMP CCopyMoveToMenu::HandleMenuMsg ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
override

Implements IContextMenu2.

Definition at line 410 of file CCopyMoveToMenu.cpp.

411{
412 TRACE("This %p uMsg %x\n", this, uMsg);
413 return E_NOTIMPL;
414}

◆ Initialize()

STDMETHODIMP CCopyMoveToMenu::Initialize ( PCIDLIST_ABSOLUTE  pidlFolder,
IDataObject pdtobj,
HKEY  hkeyProgID 
)
override

Implements IShellExtInit.

Definition at line 417 of file CCopyMoveToMenu.cpp.

418{
419 m_pidlFolder.Attach(ILClone(pidlFolder));
420 m_pDataObject = pdtobj;
421 return S_OK;
422}
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237

◆ InvokeCommand()

STDMETHODIMP CCopyMoveToMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
override

Implements IContextMenu.

Definition at line 376 of file CCopyMoveToMenu.cpp.

377{
378 HRESULT hr = E_FAIL;
379 TRACE("CCopyMoveToMenu::InvokeCommand(%p)\n", lpici);
380
381 if (IS_INTRESOURCE(lpici->lpVerb))
382 {
383 if (m_idCmdFirst + LOWORD(lpici->lpVerb) == m_idCmdAction)
384 hr = DoAction(lpici);
385 }
386 else
387 {
388 if (::lstrcmpiA(lpici->lpVerb, GetVerb()) == 0)
389 hr = DoAction(lpici);
390 }
391
392 return hr;
393}
HRESULT DoAction(LPCMINVOKECOMMANDINFO lpici)
virtual LPCSTR GetVerb() const =0
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define LOWORD(l)
Definition: pedump.c:82
#define IS_INTRESOURCE(i)
Definition: winuser.h:580

◆ SetSite()

STDMETHODIMP CCopyMoveToMenu::SetSite ( IUnknown pUnkSite)
override

Implements IObjectWithSite.

Definition at line 425 of file CCopyMoveToMenu.cpp.

426{
427 m_pSite = pUnkSite;
428 return S_OK;
429}

Member Data Documentation

◆ m_bIgnoreTextBoxChange

BOOL CCopyMoveToMenu::m_bIgnoreTextBoxChange

Definition at line 26 of file CCopyMoveToMenu.h.

Referenced by BrowseCallbackProc(), and WindowProc().

◆ m_fnOldWndProc

WNDPROC CCopyMoveToMenu::m_fnOldWndProc

Definition at line 25 of file CCopyMoveToMenu.h.

Referenced by BrowseCallbackProc(), and WindowProc().

◆ m_idCmdAction

UINT CCopyMoveToMenu::m_idCmdAction
protected

◆ m_idCmdFirst

UINT CCopyMoveToMenu::m_idCmdFirst
protected

◆ m_idCmdLast

UINT CCopyMoveToMenu::m_idCmdLast
protected

◆ m_pDataObject

CComPtr<IDataObject> CCopyMoveToMenu::m_pDataObject
protected

Definition at line 17 of file CCopyMoveToMenu.h.

Referenced by DoAction(), DoRealFileOp(), and Initialize().

◆ m_pidlFolder

CComHeapPtr<ITEMIDLIST> CCopyMoveToMenu::m_pidlFolder

Definition at line 24 of file CCopyMoveToMenu.h.

Referenced by BrowseCallbackProc(), DoAction(), and Initialize().

◆ m_pSite

CComPtr<IUnknown> CCopyMoveToMenu::m_pSite
protected

Definition at line 18 of file CCopyMoveToMenu.h.

Referenced by GetSite(), and SetSite().


The documentation for this class was generated from the following files: