- refresh folder when deleting an item

- does not work for items placed on desktop yet because the desktop folder doesnot implement IPersistFolder2 interface
- avoid using ISFHelper interface

svn path=/trunk/; revision=30029
This commit is contained in:
Johannes Anderwald 2007-10-31 22:56:24 +00:00
parent c5f01afb3d
commit f2ff1a8c8a
2 changed files with 57 additions and 12 deletions

View file

@ -1170,7 +1170,7 @@ ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCWSTR pwszName,
* Builds a list of paths like the one used in SHFileOperation from a table of * Builds a list of paths like the one used in SHFileOperation from a table of
* PIDLs relative to the given base folder * PIDLs relative to the given base folder
*/ */
static WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls) WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls)
{ {
WCHAR *wszPathsList; WCHAR *wszPathsList;
WCHAR *wszListPos; WCHAR *wszListPos;

View file

@ -23,7 +23,7 @@
#define COBJMACROS #define COBJMACROS
#define NONAMELESSUNION #define NONAMELESSUNION
#define NONAMELESSSTRUCT #define NONAMELESSSTRUCT
//#define YDEBUG #define YDEBUG
#include "winerror.h" #include "winerror.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -64,6 +64,7 @@ typedef struct
UINT UINT
SH_EnumerateDynamicContextHandlerForKey(LPWSTR szFileClass, ItemCmImpl *This, IDataObject * pDataObj, LPITEMIDLIST pidlFolder); SH_EnumerateDynamicContextHandlerForKey(LPWSTR szFileClass, ItemCmImpl *This, IDataObject * pDataObj, LPITEMIDLIST pidlFolder);
WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls);
static const IContextMenu2Vtbl cmvt; static const IContextMenu2Vtbl cmvt;
@ -510,17 +511,61 @@ static void DoRename(
* *
* deletes the currently selected items * deletes the currently selected items
*/ */
static void DoDelete(IContextMenu2 *iface) static void DoDelete(IContextMenu2 *iface, HWND hwnd)
{ {
ItemCmImpl *This = (ItemCmImpl *)iface; ItemCmImpl *This = (ItemCmImpl *)iface;
ISFHelper * psfhlp; WCHAR szPath[MAX_PATH];
WCHAR * szTarget;
SHFILEOPSTRUCTW op;
LPSHELLBROWSER lpSB;
LPSHELLVIEW lpSV;
IPersistFolder3 * psf;
LPITEMIDLIST pidl;
STRRET strTemp;
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlp); if (IShellFolder2_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&psf) != S_OK)
if (psfhlp) {
ERR("Failed to get interface IID_IPersistFolder2\n");
return;
}
if (IPersistFolder2_GetCurFolder(psf, &pidl) != S_OK)
{
ERR("IPersistFolder2_GetCurFolder failed\n");
IShellFolder2_Release(psf);
return;
}
if (IShellFolder2_GetDisplayNameOf(This->pSFParent, pidl, SHGDN_FORPARSING, &strTemp) != S_OK)
{
ERR("IShellFolder_GetDisplayNameOf failed\n");
IShellFolder2_Release(psf);
return;
}
StrRetToBufW(&strTemp, pidl, szPath, MAX_PATH);
IShellFolder2_Release(psf);
szTarget = build_paths_list(szPath, This->cidl, This->apidl);
if (pidl)
{
if (SHGetPathFromIDListW(pidl, szPath))
{
ZeroMemory(&op, sizeof(op));
op.hwnd = GetActiveWindow();
op.wFunc = FO_DELETE;
op.pFrom = szTarget;
op.fFlags = FOF_ALLOWUNDO;
SHFileOperationW(&op);
}
}
if ((lpSB = (LPSHELLBROWSER)SendMessageA(hwnd, CWM_GETISHELLBROWSER,0,0)))
{ {
ISFHelper_DeleteItems(psfhlp, This->cidl, (LPCITEMIDLIST *)This->apidl); if (SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV)))
ISFHelper_Release(psfhlp); {
} IShellView_Refresh(lpSV);
}
}
} }
/************************************************************************** /**************************************************************************
@ -673,7 +718,7 @@ static HRESULT WINAPI ISvItemCm_fnInvokeCommand(
break; break;
case FCIDM_SHVIEW_DELETE: case FCIDM_SHVIEW_DELETE:
TRACE("Verb FCIDM_SHVIEW_DELETE\n"); TRACE("Verb FCIDM_SHVIEW_DELETE\n");
DoDelete(iface); DoDelete(iface, lpcmi->hwnd);
break; break;
case FCIDM_SHVIEW_COPY: case FCIDM_SHVIEW_COPY:
TRACE("Verb FCIDM_SHVIEW_COPY\n"); TRACE("Verb FCIDM_SHVIEW_COPY\n");
@ -690,7 +735,7 @@ static HRESULT WINAPI ISvItemCm_fnInvokeCommand(
default: default:
if (LOWORD(lpcmi->lpVerb) >= This->iIdSHEFirst && LOWORD(lpcmi->lpVerb) <= This->iIdSHELast) if (LOWORD(lpcmi->lpVerb) >= This->iIdSHEFirst && LOWORD(lpcmi->lpVerb) <= This->iIdSHELast)
{ {
return DoShellExtensions(iface, lpcmi); return DoShellExtensions(This, lpcmi);
} }
FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb)); FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb));
} }
@ -699,7 +744,7 @@ static HRESULT WINAPI ISvItemCm_fnInvokeCommand(
{ {
TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb)); TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb));
if (strcmp(lpcmi->lpVerb,"delete")==0) if (strcmp(lpcmi->lpVerb,"delete")==0)
DoDelete(iface); DoDelete(iface, lpcmi->hwnd);
else else
FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb)); FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb));
} }