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"
|
2000-08-03 06:19:24 +02:00
|
|
|
#include "shlguid.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "shlobj.h"
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
#include "shell32_main.h"
|
|
|
|
#include "shellfolder.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
|
2005-06-06 21:50:35 +02:00
|
|
|
{ const IContextMenu2Vtbl *lpVtbl;
|
2005-07-03 14:03:35 +02:00
|
|
|
LONG ref;
|
2000-02-20 19:46:28 +01:00
|
|
|
IShellFolder* pSFParent;
|
|
|
|
LPITEMIDLIST pidl; /* root pidl */
|
|
|
|
LPITEMIDLIST *apidl; /* array of child pidls */
|
|
|
|
UINT cidl;
|
|
|
|
BOOL bAllValues;
|
|
|
|
} ItemCmImpl;
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
*/
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, 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));
|
2003-04-10 20:17:34 +02:00
|
|
|
cm->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);
|
|
|
|
|
2003-09-09 21:32:36 +02:00
|
|
|
return (IContextMenu2*)cm;
|
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
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)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
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
TRACE("(%p)->(count=%lu)\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
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
TRACE("(%p)->(count=%li)\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);
|
|
|
|
|
|
|
|
if(This->pidl)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ICM_InsertItem()
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2000-02-20 19:46:28 +01:00
|
|
|
void WINAPI _InsertMenuItem (
|
|
|
|
HMENU hmenu,
|
|
|
|
UINT indexMenu,
|
|
|
|
BOOL fByPosition,
|
|
|
|
UINT wID,
|
|
|
|
UINT fType,
|
2005-06-07 22:30:30 +02:00
|
|
|
LPCSTR dwTypeData,
|
2000-02-20 19:46:28 +01:00
|
|
|
UINT fState)
|
|
|
|
{
|
|
|
|
MENUITEMINFOA mii;
|
|
|
|
|
|
|
|
ZeroMemory(&mii, sizeof(mii));
|
|
|
|
mii.cbSize = sizeof(mii);
|
|
|
|
if (fType == MFT_SEPARATOR)
|
|
|
|
{
|
|
|
|
mii.fMask = MIIM_ID | MIIM_TYPE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
2005-06-09 11:46:23 +02:00
|
|
|
mii.dwTypeData = (LPSTR) dwTypeData;
|
2000-02-20 19:46:28 +01:00
|
|
|
mii.fState = fState;
|
|
|
|
}
|
|
|
|
mii.wID = wID;
|
|
|
|
mii.fType = fType;
|
|
|
|
InsertMenuItemA( hmenu, indexMenu, fByPosition, &mii);
|
|
|
|
}
|
2004-09-20 23:46:11 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* ISvItemCm_fnQueryContextMenu()
|
2004-09-20 23:46:11 +02:00
|
|
|
* FIXME: load menu MENU_SHV_FILE out of resources instead if creating
|
|
|
|
* each menu item by calling _InsertMenuItem()
|
2000-02-20 19:46:28 +01:00
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2002-11-22 00:56:42 +01: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
|
|
|
|
2004-09-20 23:46:11 +02:00
|
|
|
if (idCmdFirst != 0)
|
|
|
|
FIXME("We should use idCmdFirst=%d and idCmdLast=%d for command ids\n", idCmdFirst, idCmdLast);
|
|
|
|
|
|
|
|
if(!(CMF_DEFAULTONLY & uFlags) && This->cidl>0)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2004-09-20 23:46:11 +02:00
|
|
|
if(!(uFlags & CMF_EXPLORE))
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_OPEN, MFT_STRING, "&Select", MFS_ENABLED);
|
|
|
|
|
|
|
|
if(This->bAllValues)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2004-09-20 23:46:11 +02:00
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_OPEN, MFT_STRING, "&Open", MFS_ENABLED);
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_EXPLORE, MFT_STRING, "&Explore", MFS_ENABLED);
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-20 23:46:11 +02:00
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_EXPLORE, MFT_STRING, "&Explore", MFS_ENABLED);
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_OPEN, MFT_STRING, "&Open", MFS_ENABLED);
|
2000-02-20 19:46:28 +01:00
|
|
|
}
|
2004-09-20 23:46:11 +02:00
|
|
|
|
|
|
|
SetMenuDefaultItem(hmenu, 0, MF_BYPOSITION);
|
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_COPY, MFT_STRING, "&Copy", MFS_ENABLED);
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_CUT, MFT_STRING, "&Cut", MFS_ENABLED);
|
|
|
|
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_DELETE, MFT_STRING, "&Delete", MFS_ENABLED);
|
|
|
|
|
|
|
|
if(uFlags & CMF_CANRENAME)
|
|
|
|
_InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_RENAME, MFT_STRING, "&Rename", ISvItemCm_CanRenameItems(This) ? MFS_ENABLED : MFS_DISABLED);
|
|
|
|
|
|
|
|
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (FCIDM_SHVIEWLAST));
|
|
|
|
}
|
|
|
|
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* DoOpenExplore
|
|
|
|
*
|
|
|
|
* for folders only
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void DoOpenExplore(
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *iface,
|
2000-02-20 19:46:28 +01:00
|
|
|
HWND hwnd,
|
|
|
|
LPCSTR verb)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
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
|
|
|
|
*/
|
|
|
|
static void DoRename(
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *iface,
|
2000-02-20 19:46:28 +01:00
|
|
|
HWND hwnd)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
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
|
|
|
|
*/
|
2003-09-09 21:32:36 +02:00
|
|
|
static void DoDelete(IContextMenu2 *iface)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
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
|
|
|
*/
|
|
|
|
static BOOL DoCopyOrCut(
|
2003-09-09 21:32:36 +02:00
|
|
|
IContextMenu2 *iface,
|
2000-02-20 19:46:28 +01:00
|
|
|
HWND hwnd,
|
|
|
|
BOOL bCut)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
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;
|
|
|
|
}
|
|
|
|
/**************************************************************************
|
|
|
|
* 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)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)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)
|
|
|
|
{
|
|
|
|
switch(LOWORD(lpcmi->lpVerb))
|
|
|
|
{
|
|
|
|
case FCIDM_SHVIEW_EXPLORE:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_EXPLORE\n");
|
|
|
|
DoOpenExplore(iface, lpcmi->hwnd, "explore");
|
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_OPEN:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_OPEN\n");
|
|
|
|
DoOpenExplore(iface, lpcmi->hwnd, "open");
|
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_RENAME:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_RENAME\n");
|
|
|
|
DoRename(iface, lpcmi->hwnd);
|
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_DELETE:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_DELETE\n");
|
|
|
|
DoDelete(iface);
|
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_COPY:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_COPY\n");
|
|
|
|
DoCopyOrCut(iface, lpcmi->hwnd, FALSE);
|
|
|
|
break;
|
|
|
|
case FCIDM_SHVIEW_CUT:
|
|
|
|
TRACE("Verb FCIDM_SHVIEW_CUT\n");
|
|
|
|
DoCopyOrCut(iface, lpcmi->hwnd, TRUE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb));
|
|
|
|
if (strcmp(lpcmi->lpVerb,"delete")==0)
|
|
|
|
DoDelete(iface);
|
|
|
|
else
|
|
|
|
FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb));
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
TRACE("(%p)->(idcom=%x flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
|
|
|
|
|
|
|
|
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:
|
|
|
|
switch(idCommand)
|
|
|
|
{
|
|
|
|
case FCIDM_SHVIEW_RENAME:
|
|
|
|
strcpy((LPSTR)lpszName, "rename");
|
|
|
|
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:
|
|
|
|
switch(idCommand)
|
|
|
|
{ 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)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ItemCmImpl *This = (ItemCmImpl *)iface;
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(msg=%x wp=%x lp=%lx)\n",This, uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
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
|
|
|
};
|