ReactOS 0.4.16-dev-303-g11d5cb8
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 QueryContextMenuImpl (BOOL IsCopyOp, HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
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 (const CIDA *pCIDA, LPCMINVOKECOMMANDINFO lpici, PCUIDLIST_ABSOLUTE pidlDestination)
 
HRESULT DoAction (LPCMINVOKECOMMANDINFO lpici)
 

Protected Attributes

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 14 of file CCopyMoveToMenu.cpp.

14 :
17{
18}
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 189 of file CCopyMoveToMenu.cpp.

190{
191 WCHAR wszPath[MAX_PATH];
192 TRACE("(%p)\n", lpici);
193
194 CDataObjectHIDA pCIDA(m_pDataObject);
195 HRESULT hr = pCIDA.hr();
197 {
198 ERR("Failed to get CIDA, %#x\n", hr);
199 return hr;
200 }
201
202 if (!SHGetPathFromIDListW(m_pidlFolder, wszPath))
203 {
204 ERR("SHGetPathFromIDListW failed\n");
205 return E_FAIL;
206 }
207
208 CStringW strFileTitle;
209 hr = DoGetFileTitle(pCIDA, strFileTitle);
210 if (FAILED(hr))
211 return hr;
212
213 CStringW strTitle;
214 strTitle.Format(GetActionTitleStringID(), static_cast<LPCWSTR>(strFileTitle));
215
216 BROWSEINFOW info = { lpici->hwnd };
217 info.pidlRoot = NULL;
218 info.lpszTitle = strTitle;
221 info.lParam = reinterpret_cast<LPARAM>(this);
223 if (pidl)
224 hr = DoRealFileOp(pCIDA, lpici, pidl);
225
226 return hr;
227}
static HRESULT DoGetFileTitle(const CIDA *pCIDA, CStringW &strTitle)
#define ERR(fmt,...)
Definition: precomp.h:57
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
CComHeapPtr< ITEMIDLIST > m_pidlFolder
HRESULT DoRealFileOp(const CIDA *pCIDA, LPCMINVOKECOMMANDINFO lpici, PCUIDLIST_ABSOLUTE pidlDestination)
virtual UINT GetActionTitleStringID() const =0
CComPtr< IDataObject > m_pDataObject
#define E_FAIL
Definition: ddrawi.h:102
#define MAX_PATH
Definition: compat.h:34
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
#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:1452
HRESULT hr
Definition: shlfolder.c:183
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1217
#define BIF_USENEWUI
Definition: shlobj.h:1224
#define SHBrowseForFolder
Definition: shlobj.h:1253
#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 ( const CIDA pCIDA,
LPCMINVOKECOMMANDINFO  lpici,
PCUIDLIST_ABSOLUTE  pidlDestination 
)
protected

Definition at line 124 of file CCopyMoveToMenu.cpp.

125{
126 CStringW strFiles;
128 for (UINT n = 0; n < pCIDA->cidl; ++n)
129 {
131 if (!pidlCombine)
132 return E_FAIL;
133
134 if (!SHGetPathFromIDListW(pidlCombine, szPath))
135 return E_FAIL;
136
137 if (n > 0)
138 strFiles += L'|';
139 strFiles += szPath;
140 }
141
142 strFiles += L'|'; // double null-terminated
143 strFiles.Replace(L'|', L'\0');
144
145 if (_ILIsDesktop(pidlDestination))
147 else
148 SHGetPathFromIDListW(pidlDestination, szPath);
149 INT cchPath = lstrlenW(szPath);
150 if (cchPath + 1 < MAX_PATH)
151 {
152 szPath[cchPath + 1] = 0; // double null-terminated
153 }
154 else
155 {
156 ERR("Too long path\n");
157 return E_FAIL;
158 }
159
160 SHFILEOPSTRUCTW op = { lpici->hwnd, GetFileOp(), strFiles, szPath };
161 op.fFlags = FOF_ALLOWUNDO;
162 int res = SHFileOperationW(&op);
163 if (res)
164 {
165 ERR("SHFileOperationW failed with 0x%x\n", res);
166 return E_FAIL;
167 }
168 return S_OK;
169}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:886
virtual UINT GetFileOp() const =0
#define TRUE
Definition: types.h:120
UINT op
Definition: effect.c:236
#define lstrlenW
Definition: compat.h:750
PIDLIST_ABSOLUTE SHELL_CIDA_ILCloneFull(_In_ const CIDA *pCIDA, _In_ UINT Index)
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
#define FOF_ALLOWUNDO
Definition: shellapi.h:148
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1990
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2188
UINT cidl
Definition: shlobj.h:572
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 336 of file CCopyMoveToMenu.cpp.

342{
343 if ((uType | GCS_UNICODE) == GCS_VALIDATEW)
344 return idCmd == IDC_ACTION ? S_OK : S_FALSE;
345
346 if (uType == GCS_VERBW && idCmd == IDC_ACTION)
347 return SHAnsiToUnicode(GetVerb(), (LPWSTR)pszName, cchMax);
348
349 FIXME("%p %lu %u %p %p %u\n", this,
350 idCmd, uType, pwReserved, pszName, cchMax);
351
352 return E_NOTIMPL;
353}
UINT cchMax
#define IDC_ACTION
Definition: resource.h:44
#define FIXME(fmt,...)
Definition: precomp.h:53
virtual LPCSTR GetVerb() const =0
#define E_NOTIMPL
Definition: ddrawi.h:99
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2673
#define S_FALSE
Definition: winerror.h:2357
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ GetFileOp()

virtual UINT CCopyMoveToMenu::GetFileOp ( ) const
pure virtual

Implemented in CCopyToMenu, and CMoveToMenu.

Referenced by BrowseCallbackProc(), and DoRealFileOp().

◆ GetSite()

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

Definition at line 394 of file CCopyMoveToMenu.cpp.

395{
396 if (!m_pSite)
397 return E_FAIL;
398
399 return m_pSite->QueryInterface(riid, ppvSite);
400}
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 GetCommandString(), and InvokeCommand().

◆ HandleMenuMsg()

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

Implements IContextMenu2.

Definition at line 356 of file CCopyMoveToMenu.cpp.

357{
358 TRACE("This %p uMsg %x\n", this, uMsg);
359 return E_NOTIMPL;
360}

◆ Initialize()

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

Implements IShellExtInit.

Definition at line 363 of file CCopyMoveToMenu.cpp.

364{
365 m_pDataObject = pdtobj;
366 HRESULT hr = E_FAIL;
367 if (pidlFolder)
368 {
369 hr = SHILClone(pidlFolder, &pidlFolder);
370 }
371 else
372 {
373 pidlFolder = SHELL_DataObject_ILCloneFullItem(pdtobj, 0);
374 if (pidlFolder)
375 {
376 ILRemoveLastID((LPITEMIDLIST)pidlFolder);
377 hr = S_OK;
378 }
379 }
380
381 if (SUCCEEDED(hr))
382 m_pidlFolder.Attach(const_cast<PIDLIST_ABSOLUTE>(pidlFolder));
383 return hr;
384}
PIDLIST_ABSOLUTE SHELL_DataObject_ILCloneFullItem(_In_ IDataObject *pDO, _In_ UINT Index)
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:46
#define SUCCEEDED(hr)
Definition: intsafe.h:50
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:221
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

◆ InvokeCommand()

STDMETHODIMP CCopyMoveToMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
override

Implements IContextMenu.

Definition at line 316 of file CCopyMoveToMenu.cpp.

317{
318 HRESULT hr = E_FAIL;
319 TRACE("CCopyMoveToMenu::InvokeCommand(%p)\n", lpici);
320
321 if (IS_INTRESOURCE(lpici->lpVerb))
322 {
323 if (LOWORD(lpici->lpVerb) == IDC_ACTION)
324 hr = DoAction(lpici);
325 }
326 else
327 {
328 if (::lstrcmpiA(lpici->lpVerb, GetVerb()) == 0)
329 hr = DoAction(lpici);
330 }
331
332 return hr;
333}
HRESULT DoAction(LPCMINVOKECOMMANDINFO lpici)
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4224
#define LOWORD(l)
Definition: pedump.c:82
#define IS_INTRESOURCE(i)
Definition: winuser.h:580

◆ QueryContextMenuImpl()

STDMETHODIMP CCopyMoveToMenu::QueryContextMenuImpl ( BOOL  IsCopyOp,
HMENU  hMenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)

Definition at line 269 of file CCopyMoveToMenu.cpp.

270{
271 if (uFlags & (CMF_NOVERBS | CMF_VERBSONLY))
272 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
273
274 UINT idHighest = 0;
275 CStringW strCopyTo(MAKEINTRESOURCEW(IDS_COPYTOMENU)), strMoveTo;
276 LPWSTR itemText = strCopyTo.GetBuffer();
277 if (!IsCopyOp)
278 {
279 strMoveTo.LoadString(IDS_MOVETOMENU);
280 itemText = strMoveTo.GetBuffer();
281 }
282
283 // Insert separator if necessary
284 WCHAR szBuff[128];
285 MENUITEMINFOW mii = { sizeof(mii), MIIM_TYPE };
286 mii.dwTypeData = szBuff;
287 mii.cch = _countof(szBuff);
288 if (GetPreviousMenuItemInfo(hMenu, indexMenu, &mii) &&
289 mii.fType != MFT_SEPARATOR &&
290 (IsCopyOp || !(mii.fType == MFT_STRING && !wcscmp(szBuff, strCopyTo.GetBuffer()))))
291 {
292 mii.fMask = MIIM_TYPE;
293 mii.fType = MFT_SEPARATOR;
294 mii.dwTypeData = NULL;
295 mii.cch = 0;
296 if (InsertMenuItemW(hMenu, indexMenu, TRUE, &mii))
297 {
298 ++indexMenu;
299 }
300 }
301
302 // Insert the menu item
303 mii.fMask = MIIM_ID | MIIM_TYPE;
304 mii.fType = MFT_STRING;
305 mii.dwTypeData = itemText;
306 mii.wID = idCmdFirst + IDC_ACTION;
307 if (InsertMenuItemW(hMenu, indexMenu, TRUE, &mii))
308 {
309 idHighest = max(idHighest, mii.wID);
310 ++indexMenu;
311 }
312 return idHighest >= idCmdFirst ? MAKE_HRESULT(SEVERITY_SUCCESS, 0, idHighest - idCmdFirst + 1) : E_FAIL;
313}
static BOOL GetPreviousMenuItemInfo(HMENU hMenu, UINT iItem, LPMENUITEMINFOW lpmii)
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:639
UINT uFlags
Definition: api.c:59
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_MOVETOMENU
Definition: shresdef.h:347
#define IDS_COPYTOMENU
Definition: shresdef.h:343
#define _countof(array)
Definition: sndvol32.h:70
LPWSTR dwTypeData
Definition: winuser.h:3272
#define max(a, b)
Definition: svc.c:63
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define MIIM_ID
Definition: winuser.h:725
#define MFT_SEPARATOR
Definition: winuser.h:747
#define MFT_STRING
Definition: winuser.h:749
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define MIIM_TYPE
Definition: winuser.h:728
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

Referenced by CCopyToMenu::QueryContextMenu(), and CMoveToMenu::QueryContextMenu().

◆ SetSite()

STDMETHODIMP CCopyMoveToMenu::SetSite ( IUnknown pUnkSite)
override

Implements IObjectWithSite.

Definition at line 387 of file CCopyMoveToMenu.cpp.

388{
389 m_pSite = pUnkSite;
390 return S_OK;
391}

Member Data Documentation

◆ m_bIgnoreTextBoxChange

BOOL CCopyMoveToMenu::m_bIgnoreTextBoxChange

Definition at line 25 of file CCopyMoveToMenu.h.

Referenced by BrowseCallbackProc(), and WindowProc().

◆ m_fnOldWndProc

WNDPROC CCopyMoveToMenu::m_fnOldWndProc

Definition at line 24 of file CCopyMoveToMenu.h.

Referenced by BrowseCallbackProc(), and WindowProc().

◆ m_pDataObject

CComPtr<IDataObject> CCopyMoveToMenu::m_pDataObject
protected

Definition at line 16 of file CCopyMoveToMenu.h.

Referenced by DoAction(), and Initialize().

◆ m_pidlFolder

CComHeapPtr<ITEMIDLIST> CCopyMoveToMenu::m_pidlFolder

Definition at line 23 of file CCopyMoveToMenu.h.

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

◆ m_pSite

CComPtr<IUnknown> CCopyMoveToMenu::m_pSite
protected

Definition at line 17 of file CCopyMoveToMenu.h.

Referenced by GetSite(), and SetSite().


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