2000-02-20 19:46:28 +01:00
|
|
|
/*
|
|
|
|
* IContextMenu for items in the shellview
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 1998, 2000 Juergen Schmied <juergen.schmied@debitel.net>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-02-20 19:46:28 +01:00
|
|
|
*/
|
2002-03-10 00:29:33 +01:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
#include "winerror.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "wingdi.h"
|
2000-02-20 19:46:28 +01:00
|
|
|
#include "pidl.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "shlobj.h"
|
2010-03-16 01:32:46 +01:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "prsht.h"
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
#include "shell32_main.h"
|
|
|
|
#include "shellfolder.h"
|
|
|
|
|
2007-12-01 20:47:23 +01:00
|
|
|
#include "shresdef.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IContextMenu Implementation
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
typedef struct
|
2011-06-05 23:47:45 +02:00
|
|
|
{
|
2011-08-01 23:47:43 +02:00
|
|
|
IContextMenu2 IContextMenu2_iface;
|
|
|
|
LONG ref;
|
|
|
|
IShellFolder* pSFParent;
|
|
|
|
LPITEMIDLIST pidl; /* root pidl */
|
|
|
|
LPITEMIDLIST *apidl; /* array of child pidls */
|
|
|
|
UINT cidl;
|
|
|
|
BOOL bAllValues;
|
|
|
|
UINT verb_offset;
|
2000-02-20 19:46:28 +01:00
|
|
|
} ItemCmImpl;
|
|
|
|
|
2011-06-05 23:47:45 +02:00
|
|
|
static inline ItemCmImpl *impl_from_IContextMenu2(IContextMenu2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ItemCmImpl, IContextMenu2_iface);
|
|
|
|
}
|
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IContextMenu2Vtbl cmvt;
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_CanRenameItems()
|
|
|
|
*/
|
|
|
|
static BOOL ISvItemCm_CanRenameItems(ItemCmImpl *This)
|
|
|
|
{ UINT i;
|
|
|
|
DWORD dwAttributes;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
|
|
|
if(This->apidl)
|
|
|
|
{
|
|
|
|
for(i = 0; i < This->cidl; i++){}
|
|
|
|
if(i > 1) return FALSE; /* can't rename more than one item at a time*/
|
|
|
|
dwAttributes = SFGAO_CANRENAME;
|
2003-09-02 03:01:06 +02:00
|
|
|
IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)This->apidl, &dwAttributes);
|
2000-02-20 19:46:28 +01:00
|
|
|
return dwAttributes & SFGAO_CANRENAME;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_Constructor()
|
|
|
|
*/
|
2007-11-03 18:02:49 +01:00
|
|
|
IContextMenu2 *ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *apidl, UINT cidl)
|
2000-02-20 19:46:28 +01:00
|
|
|
{ ItemCmImpl* cm;
|
|
|
|
UINT u;
|
|
|
|
|
2005-03-21 12:25:13 +01:00
|
|
|
cm = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ItemCmImpl));
|
2011-06-05 23:47:45 +02:00
|
|
|
cm->IContextMenu2_iface.lpVtbl = &cmvt;
|
2000-02-20 19:46:28 +01:00
|
|
|
cm->ref = 1;
|
|
|
|
cm->pidl = ILClone(pidl);
|
|
|
|
cm->pSFParent = pSFParent;
|
|
|
|
|
|
|
|
if(pSFParent) IShellFolder_AddRef(pSFParent);
|
|
|
|
|
|
|
|
cm->apidl = _ILCopyaPidl(apidl, cidl);
|
|
|
|
cm->cidl = cidl;
|
|
|
|
|
|
|
|
cm->bAllValues = 1;
|
|
|
|
for(u = 0; u < cidl; u++)
|
|
|
|
{
|
|
|
|
cm->bAllValues &= (_ILIsValue(apidl[u]) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",cm);
|
|
|
|
|
2011-06-05 23:47:45 +02:00
|
|
|
return &cm->IContextMenu2_iface;
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnQueryInterface
|
|
|
|
*/
|
2003-09-09 21:32:36 +02:00
|
|
|
static HRESULT WINAPI ISvItemCm_fnQueryInterface(IContextMenu2 *iface, REFIID riid, LPVOID *ppvObj)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2011-06-05 23:47:45 +02:00
|
|
|
ItemCmImpl *This = impl_from_IContextMenu2(iface);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
|
|
|
|
|
|
|
|
*ppvObj = NULL;
|
|
|
|
|
2003-09-09 21:32:36 +02:00
|
|
|
if(IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IContextMenu) ||
|
|
|
|
IsEqualIID(riid, &IID_IContextMenu2))
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
|
|
|
*ppvObj = This;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-02-20 19:46:28 +01:00
|
|
|
else if(IsEqualIID(riid, &IID_IShellExtInit)) /*IShellExtInit*/
|
|
|
|
{
|
|
|
|
FIXME("-- LPSHELLEXTINIT pointer requested\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppvObj)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObj);
|
2000-02-20 19:46:28 +01:00
|
|
|
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
TRACE("-- Interface: E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnAddRef
|
|
|
|
*/
|
2003-09-09 21:32:36 +02:00
|
|
|
static ULONG WINAPI ISvItemCm_fnAddRef(IContextMenu2 *iface)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2011-06-05 23:47:45 +02:00
|
|
|
ItemCmImpl *This = impl_from_IContextMenu2(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, refCount - 1);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnRelease
|
|
|
|
*/
|
2003-09-09 21:32:36 +02:00
|
|
|
static ULONG WINAPI ISvItemCm_fnRelease(IContextMenu2 *iface)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2011-06-05 23:47:45 +02:00
|
|
|
ItemCmImpl *This = impl_from_IContextMenu2(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%i)\n", This, refCount + 1);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
if (!refCount)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
|
|
|
TRACE(" destroying IContextMenu(%p)\n",This);
|
|
|
|
|
|
|
|
if(This->pSFParent)
|
|
|
|
IShellFolder_Release(This->pSFParent);
|
|
|
|
|
2006-10-07 03:06:26 +02:00
|
|
|
SHFree(This->pidl);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
/*make sure the pidl is freed*/
|
|
|
|
_ILFreeaPidl(This->apidl, This->cidl);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
|
|
|
|
2007-12-03 15:49:51 +01:00
|
|
|
static void _InsertMenuItemW (
|
2007-12-01 20:47:23 +01:00
|
|
|
HMENU hmenu,
|
|
|
|
UINT indexMenu,
|
|
|
|
BOOL fByPosition,
|
|
|
|
UINT wID,
|
|
|
|
UINT fType,
|
|
|
|
LPWSTR dwTypeData,
|
|
|
|
UINT fState)
|
|
|
|
{
|
|
|
|
MENUITEMINFOW mii;
|
|
|
|
|
|
|
|
mii.cbSize = sizeof(mii);
|
|
|
|
if (fType == MFT_SEPARATOR)
|
|
|
|
{
|
|
|
|
mii.fMask = MIIM_ID | MIIM_TYPE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
|
|
|
mii.dwTypeData = dwTypeData;
|
|
|
|
mii.fState = fState;
|
|
|
|
}
|
|
|
|
mii.wID = wID;
|
|
|
|
mii.fType = fType;
|
|
|
|
InsertMenuItemW( hmenu, indexMenu, fByPosition, &mii);
|
|
|
|
}
|
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnQueryContextMenu()
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISvItemCm_fnQueryContextMenu(
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *iface,
|
2000-02-20 19:46:28 +01:00
|
|
|
HMENU hmenu,
|
|
|
|
UINT indexMenu,
|
|
|
|
UINT idCmdFirst,
|
|
|
|
UINT idCmdLast,
|
|
|
|
UINT uFlags)
|
|
|
|
{
|
2011-08-01 23:47:43 +02:00
|
|
|
ItemCmImpl *This = impl_from_IContextMenu2(iface);
|
|
|
|
INT uIDMax;
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",This, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
This->verb_offset=idCmdFirst;
|
2004-09-20 23:46:11 +02:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
if(!(CMF_DEFAULTONLY & uFlags) && This->cidl>0)
|
|
|
|
{
|
|
|
|
HMENU hmenures = LoadMenuW(shell32_hInstance, MAKEINTRESOURCEW(MENU_SHV_FILE));
|
2007-12-01 20:47:23 +01:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
if(uFlags & CMF_EXPLORE)
|
2007-12-01 20:47:23 +01:00
|
|
|
RemoveMenu(hmenures, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);
|
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
uIDMax = Shell_MergeMenus(hmenu, GetSubMenu(hmenures, 0), indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);
|
2007-12-01 20:47:23 +01:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
DestroyMenu(hmenures);
|
2004-09-20 23:46:11 +02:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
if(This->bAllValues)
|
|
|
|
{
|
2007-12-01 20:47:23 +01:00
|
|
|
MENUITEMINFOW mi;
|
|
|
|
WCHAR str[255];
|
|
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
mi.fMask = MIIM_ID | MIIM_STRING | MIIM_FTYPE;
|
|
|
|
mi.dwTypeData = str;
|
|
|
|
mi.cch = 255;
|
|
|
|
GetMenuItemInfoW(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND, &mi);
|
|
|
|
RemoveMenu(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND);
|
|
|
|
_InsertMenuItemW(hmenu, (uFlags & CMF_EXPLORE) ? 1 : 2, MF_BYPOSITION, FCIDM_SHVIEW_EXPLORE, MFT_STRING, str, MFS_ENABLED);
|
2011-08-01 23:47:43 +02:00
|
|
|
}
|
2004-09-20 23:46:11 +02:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
SetMenuDefaultItem(hmenu, 0, MF_BYPOSITION);
|
2004-09-20 23:46:11 +02:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
if(uFlags & ~CMF_CANRENAME)
|
2007-12-01 20:47:23 +01:00
|
|
|
RemoveMenu(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND);
|
2011-08-01 23:47:43 +02:00
|
|
|
else
|
2007-12-01 20:47:23 +01:00
|
|
|
EnableMenuItem(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND | ISvItemCm_CanRenameItems(This) ? MFS_ENABLED : MFS_DISABLED);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2011-08-01 23:47:43 +02:00
|
|
|
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, uIDMax-idCmdFirst);
|
|
|
|
}
|
|
|
|
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* DoOpenExplore
|
|
|
|
*
|
|
|
|
* for folders only
|
|
|
|
*/
|
|
|
|
|
2011-06-05 23:45:04 +02:00
|
|
|
static void DoOpenExplore(ItemCmImpl *This, HWND hwnd, LPCSTR verb)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2002-12-13 01:36:52 +01:00
|
|
|
UINT i, bFolderFound = FALSE;
|
2000-02-20 19:46:28 +01:00
|
|
|
LPITEMIDLIST pidlFQ;
|
|
|
|
SHELLEXECUTEINFOA sei;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Find the first item in the list that is not a value. These commands
|
2000-02-20 19:46:28 +01:00
|
|
|
should never be invoked if there isn't at least one folder item in the list.*/
|
|
|
|
|
|
|
|
for(i = 0; i<This->cidl; i++)
|
|
|
|
{
|
|
|
|
if(!_ILIsValue(This->apidl[i]))
|
|
|
|
{
|
|
|
|
bFolderFound = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bFolderFound) return;
|
|
|
|
|
|
|
|
pidlFQ = ILCombine(This->pidl, This->apidl[i]);
|
|
|
|
|
|
|
|
ZeroMemory(&sei, sizeof(sei));
|
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
|
sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
|
|
|
|
sei.lpIDList = pidlFQ;
|
2004-09-21 22:04:59 +02:00
|
|
|
sei.lpClass = "Folder";
|
2000-02-20 19:46:28 +01:00
|
|
|
sei.hwnd = hwnd;
|
|
|
|
sei.nShow = SW_SHOWNORMAL;
|
|
|
|
sei.lpVerb = verb;
|
|
|
|
ShellExecuteExA(&sei);
|
|
|
|
SHFree(pidlFQ);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* DoRename
|
|
|
|
*/
|
2011-06-05 23:45:04 +02:00
|
|
|
static void DoRename(ItemCmImpl *This, HWND hwnd)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
|
|
|
LPSHELLBROWSER lpSB;
|
|
|
|
LPSHELLVIEW lpSV;
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("(%p)->(wnd=%p)\n",This, hwnd);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
/* get the active IShellView */
|
|
|
|
if ((lpSB = (LPSHELLBROWSER)SendMessageA(hwnd, CWM_GETISHELLBROWSER,0,0)))
|
|
|
|
{
|
|
|
|
if(SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV)))
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("(sv=%p)\n",lpSV);
|
2000-02-26 19:48:16 +01:00
|
|
|
IShellView_SelectItem(lpSV, This->apidl[0],
|
|
|
|
SVSI_DESELECTOTHERS|SVSI_EDIT|SVSI_ENSUREVISIBLE|SVSI_FOCUSED|SVSI_SELECT);
|
2000-02-20 19:46:28 +01:00
|
|
|
IShellView_Release(lpSV);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* DoDelete
|
|
|
|
*
|
|
|
|
* deletes the currently selected items
|
|
|
|
*/
|
2011-06-05 23:45:04 +02:00
|
|
|
static void DoDelete(ItemCmImpl *This)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
|
|
|
ISFHelper * psfhlp;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlp);
|
|
|
|
if (psfhlp)
|
|
|
|
{
|
2003-09-02 03:01:06 +02:00
|
|
|
ISFHelper_DeleteItems(psfhlp, This->cidl, (LPCITEMIDLIST *)This->apidl);
|
2000-02-20 19:46:28 +01:00
|
|
|
ISFHelper_Release(psfhlp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* DoCopyOrCut
|
|
|
|
*
|
2001-11-06 22:01:32 +01:00
|
|
|
* copies the currently selected items into the clipboard
|
2000-02-20 19:46:28 +01:00
|
|
|
*/
|
2011-06-05 23:45:04 +02:00
|
|
|
static BOOL DoCopyOrCut(ItemCmImpl *This, HWND hwnd, BOOL bCut)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
|
|
|
LPSHELLBROWSER lpSB;
|
|
|
|
LPSHELLVIEW lpSV;
|
|
|
|
LPDATAOBJECT lpDo;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("(%p)->(wnd=%p,bCut=0x%08x)\n",This, hwnd, bCut);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2004-06-18 02:23:38 +02:00
|
|
|
/* get the active IShellView */
|
|
|
|
if ((lpSB = (LPSHELLBROWSER)SendMessageA(hwnd, CWM_GETISHELLBROWSER,0,0)))
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2004-06-18 02:23:38 +02:00
|
|
|
if (SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV)))
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2004-06-18 02:23:38 +02:00
|
|
|
if (SUCCEEDED(IShellView_GetItemObject(lpSV, SVGIO_SELECTION, &IID_IDataObject, (LPVOID*)&lpDo)))
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2004-06-18 02:23:38 +02:00
|
|
|
OleSetClipboard(lpDo);
|
|
|
|
IDataObject_Release(lpDo);
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
2004-06-18 02:23:38 +02:00
|
|
|
IShellView_Release(lpSV);
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-03-16 01:32:46 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Properties_AddPropSheetCallback
|
|
|
|
*
|
|
|
|
* Used by DoOpenProperties through SHCreatePropSheetExtArrayEx to add
|
|
|
|
* propertysheet pages from shell extensions.
|
|
|
|
*/
|
|
|
|
static BOOL Properties_AddPropSheetCallback(HPROPSHEETPAGE hpage, LPARAM lparam)
|
|
|
|
{
|
|
|
|
LPPROPSHEETHEADERW psh = (LPPROPSHEETHEADERW) lparam;
|
|
|
|
psh->u3.phpage[psh->nPages++] = hpage;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* DoOpenProperties
|
|
|
|
*/
|
2011-06-05 23:45:04 +02:00
|
|
|
static void DoOpenProperties(ItemCmImpl *This, HWND hwnd)
|
2010-03-16 01:32:46 +01:00
|
|
|
{
|
|
|
|
static const UINT MAX_PROP_PAGES = 99;
|
|
|
|
static const WCHAR wszFolder[] = {'F','o','l','d','e','r', 0};
|
|
|
|
static const WCHAR wszFiletypeAll[] = {'*',0};
|
|
|
|
LPSHELLFOLDER lpDesktopSF;
|
|
|
|
LPSHELLFOLDER lpSF;
|
|
|
|
LPDATAOBJECT lpDo;
|
|
|
|
WCHAR wszFiletype[MAX_PATH];
|
|
|
|
WCHAR wszFilename[MAX_PATH];
|
|
|
|
PROPSHEETHEADERW psh;
|
|
|
|
HPROPSHEETPAGE hpages[MAX_PROP_PAGES];
|
|
|
|
HPSXA hpsxa;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("(%p)->(wnd=%p)\n", This, hwnd);
|
|
|
|
|
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
|
|
|
|
psh.dwSize = sizeof (PROPSHEETHEADERW);
|
|
|
|
psh.hwndParent = hwnd;
|
|
|
|
psh.dwFlags = PSH_PROPTITLE;
|
|
|
|
psh.nPages = 0;
|
|
|
|
psh.u3.phpage = hpages;
|
|
|
|
psh.u2.nStartPage = 0;
|
|
|
|
|
|
|
|
_ILSimpleGetTextW(This->apidl[0], (LPVOID)&wszFilename, MAX_PATH);
|
|
|
|
psh.pszCaption = (LPCWSTR)&wszFilename;
|
|
|
|
|
|
|
|
/* Find out where to look for the shell extensions */
|
|
|
|
if (_ILIsValue(This->apidl[0]))
|
|
|
|
{
|
|
|
|
char sTemp[64];
|
|
|
|
sTemp[0] = 0;
|
|
|
|
if (_ILGetExtension(This->apidl[0], sTemp, 64))
|
|
|
|
{
|
|
|
|
HCR_MapTypeToValueA(sTemp, sTemp, 64, TRUE);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, sTemp, -1, wszFiletype, MAX_PATH);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wszFiletype[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_ILIsFolder(This->apidl[0]))
|
|
|
|
{
|
|
|
|
lstrcpynW(wszFiletype, wszFolder, 64);
|
|
|
|
}
|
|
|
|
else if (_ILIsSpecialFolder(This->apidl[0]))
|
|
|
|
{
|
|
|
|
LPGUID folderGUID;
|
|
|
|
static const WCHAR wszclsid[] = {'C','L','S','I','D','\\', 0};
|
|
|
|
folderGUID = _ILGetGUIDPointer(This->apidl[0]);
|
|
|
|
lstrcpyW(wszFiletype, wszclsid);
|
|
|
|
StringFromGUID2(folderGUID, &wszFiletype[6], MAX_PATH - 6);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Requested properties for unknown type.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get a suitable DataObject for accessing the files */
|
|
|
|
SHGetDesktopFolder(&lpDesktopSF);
|
|
|
|
if (_ILIsPidlSimple(This->pidl))
|
|
|
|
{
|
|
|
|
ret = IShellFolder_GetUIObjectOf(lpDesktopSF, hwnd, This->cidl, (LPCITEMIDLIST*)This->apidl,
|
|
|
|
&IID_IDataObject, NULL, (LPVOID *)&lpDo);
|
|
|
|
IShellFolder_Release(lpDesktopSF);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IShellFolder_BindToObject(lpDesktopSF, This->pidl, NULL, &IID_IShellFolder, (LPVOID*) &lpSF);
|
|
|
|
ret = IShellFolder_GetUIObjectOf(lpSF, hwnd, This->cidl, (LPCITEMIDLIST*)This->apidl,
|
|
|
|
&IID_IDataObject, NULL, (LPVOID *)&lpDo);
|
|
|
|
IShellFolder_Release(lpSF);
|
|
|
|
IShellFolder_Release(lpDesktopSF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
hpsxa = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszFiletype, MAX_PROP_PAGES - psh.nPages, lpDo);
|
|
|
|
if (hpsxa != NULL)
|
|
|
|
{
|
|
|
|
SHAddFromPropSheetExtArray((HPSXA)hpsxa,
|
|
|
|
(LPFNADDPROPSHEETPAGE)&Properties_AddPropSheetCallback,
|
|
|
|
(LPARAM)&psh);
|
|
|
|
SHDestroyPropSheetExtArray(hpsxa);
|
|
|
|
}
|
|
|
|
hpsxa = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszFiletypeAll, MAX_PROP_PAGES - psh.nPages, lpDo);
|
|
|
|
if (hpsxa != NULL)
|
|
|
|
{
|
|
|
|
SHAddFromPropSheetExtArray((HPSXA)hpsxa,
|
|
|
|
(LPFNADDPROPSHEETPAGE)&Properties_AddPropSheetCallback,
|
|
|
|
(LPARAM)&psh);
|
|
|
|
SHDestroyPropSheetExtArray(hpsxa);
|
|
|
|
}
|
|
|
|
IDataObject_Release(lpDo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (psh.nPages)
|
|
|
|
PropertySheetW(&psh);
|
|
|
|
else
|
|
|
|
FIXME("No property pages found.\n");
|
|
|
|
}
|
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnInvokeCommand()
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISvItemCm_fnInvokeCommand(
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *iface,
|
2000-02-20 19:46:28 +01:00
|
|
|
LPCMINVOKECOMMANDINFO lpcmi)
|
|
|
|
{
|
2011-06-05 23:47:45 +02:00
|
|
|
ItemCmImpl *This = impl_from_IContextMenu2(iface);
|
2003-06-24 04:33:53 +02:00
|
|
|
|
|
|
|
if (lpcmi->cbSize != sizeof(CMINVOKECOMMANDINFO))
|
|
|
|
FIXME("Is an EX structure\n");
|
|
|
|
|
|
|
|
TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd);
|
|
|
|
|
|
|
|
if( HIWORD(lpcmi->lpVerb)==0 && LOWORD(lpcmi->lpVerb) > FCIDM_SHVIEWLAST)
|
|
|
|
{
|
|
|
|
TRACE("Invalid Verb %x\n",LOWORD(lpcmi->lpVerb));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HIWORD(lpcmi->lpVerb) == 0)
|
|
|
|
{
|
2011-08-01 23:47:43 +02:00
|
|
|
switch(LOWORD(lpcmi->lpVerb-This->verb_offset))
|
2003-06-24 04:33:53 +02:00
|
|
|
{
|
|
|
|
case FCIDM_SHVIEW_EXPLORE:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_EXPLORE\n");
|
2011-06-05 23:45:04 +02:00
|
|
|
DoOpenExplore(This, lpcmi->hwnd, "explore");
|
2003-06-24 04:33:53 +02:00
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_OPEN:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_OPEN\n");
|
2011-06-05 23:45:04 +02:00
|
|
|
DoOpenExplore(This, lpcmi->hwnd, "open");
|
2003-06-24 04:33:53 +02:00
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_RENAME:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_RENAME\n");
|
2011-06-05 23:45:04 +02:00
|
|
|
DoRename(This, lpcmi->hwnd);
|
2003-06-24 04:33:53 +02:00
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_DELETE:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_DELETE\n");
|
2011-06-05 23:45:04 +02:00
|
|
|
DoDelete(This);
|
2003-06-24 04:33:53 +02:00
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_COPY:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_COPY\n");
|
2011-06-05 23:45:04 +02:00
|
|
|
DoCopyOrCut(This, lpcmi->hwnd, FALSE);
|
2003-06-24 04:33:53 +02:00
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_CUT:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_CUT\n");
|
2011-06-05 23:45:04 +02:00
|
|
|
DoCopyOrCut(This, lpcmi->hwnd, TRUE);
|
2003-06-24 04:33:53 +02:00
|
|
|
break;
|
2010-03-16 01:32:46 +01:00
|
|
|
case FCIDM_SHVIEW_PROPERTIES:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n");
|
2011-06-05 23:45:04 +02:00
|
|
|
DoOpenProperties(This, lpcmi->hwnd);
|
2010-03-16 01:32:46 +01:00
|
|
|
break;
|
2003-06-24 04:33:53 +02:00
|
|
|
default:
|
2011-08-01 23:47:43 +02:00
|
|
|
FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb)-This->verb_offset);
|
2010-07-17 17:08:18 +02:00
|
|
|
return E_INVALIDARG;
|
2003-06-24 04:33:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb));
|
|
|
|
if (strcmp(lpcmi->lpVerb,"delete")==0)
|
2011-06-05 23:45:04 +02:00
|
|
|
DoDelete(This);
|
2010-03-16 01:32:46 +01:00
|
|
|
else if (strcmp(lpcmi->lpVerb,"properties")==0)
|
2011-06-05 23:45:04 +02:00
|
|
|
DoOpenProperties(This, lpcmi->hwnd);
|
2010-07-17 17:08:18 +02:00
|
|
|
else {
|
2003-06-24 04:33:53 +02:00
|
|
|
FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb));
|
2010-07-17 17:08:18 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2003-06-24 04:33:53 +02:00
|
|
|
}
|
|
|
|
return NOERROR;
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnGetCommandString()
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISvItemCm_fnGetCommandString(
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *iface,
|
2005-09-02 13:32:17 +02:00
|
|
|
UINT_PTR idCommand,
|
2000-02-20 19:46:28 +01:00
|
|
|
UINT uFlags,
|
2002-09-17 03:35:09 +02:00
|
|
|
UINT* lpReserved,
|
2000-02-20 19:46:28 +01:00
|
|
|
LPSTR lpszName,
|
|
|
|
UINT uMaxNameLen)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2011-06-05 23:47:45 +02:00
|
|
|
ItemCmImpl *This = impl_from_IContextMenu2(iface);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
switch(uFlags)
|
|
|
|
{
|
2003-09-09 21:32:36 +02:00
|
|
|
case GCS_HELPTEXTA:
|
|
|
|
case GCS_HELPTEXTW:
|
2000-02-20 19:46:28 +01:00
|
|
|
hr = E_NOTIMPL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GCS_VERBA:
|
2011-08-01 23:47:43 +02:00
|
|
|
switch(idCommand-This->verb_offset)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2011-08-01 23:47:43 +02:00
|
|
|
case FCIDM_SHVIEW_RENAME:
|
2008-01-19 17:54:31 +01:00
|
|
|
strcpy(lpszName, "rename");
|
2000-02-20 19:46:28 +01:00
|
|
|
hr = NOERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* NT 4.0 with IE 3.0x or no IE will always call This with GCS_VERBW. In This
|
2000-02-20 19:46:28 +01:00
|
|
|
case, you need to do the lstrcpyW to the pointer passed.*/
|
|
|
|
case GCS_VERBW:
|
2011-08-01 23:47:43 +02:00
|
|
|
switch(idCommand-This->verb_offset)
|
|
|
|
{
|
|
|
|
case FCIDM_SHVIEW_RENAME:
|
2000-11-28 23:40:56 +01:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, "rename", -1, (LPWSTR)lpszName, uMaxNameLen );
|
2000-02-20 19:46:28 +01:00
|
|
|
hr = NOERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-09-09 21:32:36 +02:00
|
|
|
case GCS_VALIDATEA:
|
|
|
|
case GCS_VALIDATEW:
|
2000-02-20 19:46:28 +01:00
|
|
|
hr = NOERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TRACE("-- (%p)->(name=%s)\n",This, lpszName);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnHandleMenuMsg()
|
|
|
|
* NOTES
|
|
|
|
* should be only in IContextMenu2 and IContextMenu3
|
|
|
|
* is nevertheless called from word95
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISvItemCm_fnHandleMenuMsg(
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *iface,
|
2000-02-20 19:46:28 +01:00
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2011-06-05 23:47:45 +02:00
|
|
|
ItemCmImpl *This = impl_from_IContextMenu2(iface);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("(%p)->(msg=%x wp=%lx lp=%lx)\n",This, uMsg, wParam, lParam);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IContextMenu2Vtbl cmvt =
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2000-02-20 19:46:28 +01:00
|
|
|
ISvItemCm_fnQueryInterface,
|
|
|
|
ISvItemCm_fnAddRef,
|
|
|
|
ISvItemCm_fnRelease,
|
|
|
|
ISvItemCm_fnQueryContextMenu,
|
|
|
|
ISvItemCm_fnInvokeCommand,
|
|
|
|
ISvItemCm_fnGetCommandString,
|
2003-09-09 21:32:36 +02:00
|
|
|
ISvItemCm_fnHandleMenuMsg
|
2000-02-20 19:46:28 +01:00
|
|
|
};
|