Better context menus.
This commit is contained in:
parent
e2b8804525
commit
538f30dad8
|
@ -28,6 +28,9 @@ BEGIN
|
||||||
MENUITEM "&Details", FCIDM_SHVIEW_REPORTVIEW
|
MENUITEM "&Details", FCIDM_SHVIEW_REPORTVIEW
|
||||||
END
|
END
|
||||||
|
|
||||||
|
/*
|
||||||
|
shellview background menu
|
||||||
|
*/
|
||||||
MENU_002 MENU DISCARDABLE
|
MENU_002 MENU DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
POPUP""
|
POPUP""
|
||||||
|
@ -51,28 +54,38 @@ BEGIN
|
||||||
END
|
END
|
||||||
MENUITEM "Line up Icons", FCIDM_SHVIEW_SNAPTOGRID
|
MENUITEM "Line up Icons", FCIDM_SHVIEW_SNAPTOGRID
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Refresh", FCIDM_SHVIEW_REFRESH
|
||||||
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Paste", FCIDM_SHVIEW_INSERT
|
MENUITEM "Paste", FCIDM_SHVIEW_INSERT
|
||||||
MENUITEM "Paste as Link", FCIDM_SHVIEW_INSERTLINK
|
MENUITEM "Paste as Link", FCIDM_SHVIEW_INSERTLINK
|
||||||
|
MENUITEM SEPARATOR
|
||||||
POPUP "New"
|
POPUP "New"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "New &Folder", 0x7053
|
MENUITEM "New &Folder", FCIDM_SHVIEW_NEWFOLDER
|
||||||
MENUITEM "New &Link", 0x7052
|
MENUITEM "New &Link", FCIDM_SHVIEW_NEWLINK
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
END
|
END
|
||||||
MENUITEM "Properties", FCIDM_SHVIEW_PROPERTIES
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Properties", FCIDM_SHVIEW_PROPERTIES
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
|
/*
|
||||||
|
shellview item menu
|
||||||
|
*/
|
||||||
MENU_SHV_FILE MENU DISCARDABLE
|
MENU_SHV_FILE MENU DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
POPUP""
|
POPUP""
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "C&ut", FCIDM_SHVIEW_CUT
|
MENUITEM "E&xplore", FCIDM_SHVIEW_CUT
|
||||||
MENUITEM "&Copy", FCIDM_SHVIEW_COPY
|
MENUITEM "&Open", FCIDM_SHVIEW_COPY
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "&Link", 0x7051
|
MENUITEM "C&ut", FCIDM_SHVIEW_CUT
|
||||||
MENUITEM "&Delete", FCIDM_SHVIEW_DELETE
|
MENUITEM "&Copy", FCIDM_SHVIEW_COPY
|
||||||
MENUITEM "&Rename", 0x7050
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "&Create Link", FCIDM_SHVIEW_CREATELINK
|
||||||
|
MENUITEM "&Delete", FCIDM_SHVIEW_DELETE
|
||||||
|
MENUITEM "&Rename", FCIDM_SHVIEW_RENAME
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "&Properties", FCIDM_SHVIEW_PROPERTIES
|
MENUITEM "&Properties", FCIDM_SHVIEW_PROPERTIES
|
||||||
END
|
END
|
||||||
|
@ -112,6 +125,12 @@ STRINGTABLE DISCARDABLE
|
||||||
IDS_OPEN "Open"
|
IDS_OPEN "Open"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STRINGTABLE DISCARDABLE
|
||||||
|
{
|
||||||
|
IDS_CREATEFOLDER_DENIED "Can not create new Folder: Permission denied."
|
||||||
|
IDS_CREATEFOLDER_CAPTION "Error during creating a new folder"
|
||||||
|
}
|
||||||
|
|
||||||
/* BINRES 000.ico document */
|
/* BINRES 000.ico document */
|
||||||
0 ICON
|
0 ICON
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,4 +22,7 @@
|
||||||
#define IDS_VIEW_LIST 26
|
#define IDS_VIEW_LIST 26
|
||||||
#define IDS_VIEW_DETAILS 27
|
#define IDS_VIEW_DETAILS 27
|
||||||
|
|
||||||
|
#define IDS_CREATEFOLDER_DENIED 30
|
||||||
|
#define IDS_CREATEFOLDER_CAPTION 31
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "winerror.h"
|
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
#include "pidl.h"
|
#include "pidl.h"
|
||||||
#include "wine/obj_base.h"
|
#include "wine/obj_base.h"
|
||||||
#include "wine/obj_contextmenu.h"
|
#include "wine/obj_contextmenu.h"
|
||||||
#include "wine/obj_shellbrowser.h"
|
#include "wine/obj_shellbrowser.h"
|
||||||
#include "wine/obj_shellextinit.h"
|
|
||||||
|
|
||||||
#include "shell32_main.h"
|
#include "shell32_main.h"
|
||||||
|
#include "shellfolder.h"
|
||||||
|
#include "shell.h" /* DROPFILESTRUCT */
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(shell)
|
DEFAULT_DEBUG_CHANNEL(shell)
|
||||||
|
|
||||||
|
@ -23,7 +23,9 @@ DEFAULT_DEBUG_CHANNEL(shell)
|
||||||
* IContextMenu Implementation
|
* IContextMenu Implementation
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{ ICOM_VFIELD(IContextMenu);
|
{
|
||||||
|
ICOM_VFIELD(IContextMenu);
|
||||||
|
IShellFolder* pSFParent;
|
||||||
DWORD ref;
|
DWORD ref;
|
||||||
} BgCmImpl;
|
} BgCmImpl;
|
||||||
|
|
||||||
|
@ -33,13 +35,15 @@ static struct ICOM_VTABLE(IContextMenu) cmvt;
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* ISVBgCm_Constructor()
|
* ISVBgCm_Constructor()
|
||||||
*/
|
*/
|
||||||
IContextMenu *ISvBgCm_Constructor(void)
|
IContextMenu *ISvBgCm_Constructor(IShellFolder* pSFParent)
|
||||||
{
|
{
|
||||||
BgCmImpl* cm;
|
BgCmImpl* cm;
|
||||||
|
|
||||||
cm = (BgCmImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(BgCmImpl));
|
cm = (BgCmImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(BgCmImpl));
|
||||||
ICOM_VTBL(cm)=&cmvt;
|
ICOM_VTBL(cm)=&cmvt;
|
||||||
cm->ref = 1;
|
cm->ref = 1;
|
||||||
|
cm->pSFParent = pSFParent;
|
||||||
|
if(pSFParent) IShellFolder_AddRef(pSFParent);
|
||||||
|
|
||||||
TRACE("(%p)->()\n",cm);
|
TRACE("(%p)->()\n",cm);
|
||||||
shell32_ObjCount++;
|
shell32_ObjCount++;
|
||||||
|
@ -102,14 +106,19 @@ static ULONG WINAPI ISVBgCm_fnRelease(IContextMenu *iface)
|
||||||
|
|
||||||
TRACE("(%p)->()\n",This);
|
TRACE("(%p)->()\n",This);
|
||||||
|
|
||||||
shell32_ObjCount--;
|
|
||||||
|
|
||||||
if (!--(This->ref))
|
if (!--(This->ref))
|
||||||
{ TRACE(" destroying IContextMenu(%p)\n",This);
|
{
|
||||||
|
TRACE(" destroying IContextMenu(%p)\n",This);
|
||||||
|
|
||||||
|
if(This->pSFParent)
|
||||||
|
IShellFolder_Release(This->pSFParent);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),0,This);
|
HeapFree(GetProcessHeap(),0,This);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shell32_ObjCount--;
|
||||||
|
|
||||||
return This->ref;
|
return This->ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +150,134 @@ static HRESULT WINAPI ISVBgCm_fnQueryContextMenu(
|
||||||
return ResultFromShort(idMax - idCmdFirst);
|
return ResultFromShort(idMax - idCmdFirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* DoNewFolder
|
||||||
|
*/
|
||||||
|
static void DoNewFolder(
|
||||||
|
IContextMenu *iface,
|
||||||
|
IShellView *psv)
|
||||||
|
{
|
||||||
|
ICOM_THIS(BgCmImpl, iface);
|
||||||
|
ISFHelper * psfhlp;
|
||||||
|
char szName[MAX_PATH];
|
||||||
|
|
||||||
|
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlp);
|
||||||
|
if (psfhlp)
|
||||||
|
{
|
||||||
|
LPITEMIDLIST pidl;
|
||||||
|
ISFHelper_GetUniqueName(psfhlp, szName, MAX_PATH);
|
||||||
|
ISFHelper_AddFolder(psfhlp, 0, szName, &pidl);
|
||||||
|
|
||||||
|
if(psv)
|
||||||
|
{
|
||||||
|
/* if we are in a shellview do labeledit */
|
||||||
|
IShellView_Refresh(psv); /* fixme: so long we dont have SHChangeNotify */
|
||||||
|
IShellView_SelectItem(psv,
|
||||||
|
pidl,(SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE
|
||||||
|
|SVSI_FOCUSED|SVSI_SELECT));
|
||||||
|
}
|
||||||
|
SHFree(pidl);
|
||||||
|
|
||||||
|
ISFHelper_Release(psfhlp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* DoPaste
|
||||||
|
*/
|
||||||
|
static BOOL DoPaste(
|
||||||
|
IContextMenu *iface)
|
||||||
|
{
|
||||||
|
ICOM_THIS(BgCmImpl, iface);
|
||||||
|
BOOL bSuccess = FALSE;
|
||||||
|
IDataObject * pda;
|
||||||
|
|
||||||
|
TRACE("\n");
|
||||||
|
|
||||||
|
if(SUCCEEDED(pOleGetClipboard(&pda)));
|
||||||
|
{
|
||||||
|
STGMEDIUM medium;
|
||||||
|
FORMATETC formatetc;
|
||||||
|
|
||||||
|
TRACE("pda=%p\n", pda);
|
||||||
|
|
||||||
|
/* Set the FORMATETC structure*/
|
||||||
|
InitFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
|
||||||
|
|
||||||
|
/* Get the pidls from IDataObject */
|
||||||
|
if(SUCCEEDED(IDataObject_GetData(pda,&formatetc,&medium)))
|
||||||
|
{
|
||||||
|
LPITEMIDLIST * apidl;
|
||||||
|
LPITEMIDLIST pidl;
|
||||||
|
IShellFolder *psfFrom = NULL, *psfDesktop;
|
||||||
|
|
||||||
|
LPCIDA lpcida = GlobalLock(medium.u.hGlobal);
|
||||||
|
TRACE("cida=%p\n", lpcida);
|
||||||
|
|
||||||
|
apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
|
||||||
|
|
||||||
|
/* bind to the source shellfolder */
|
||||||
|
SHGetDesktopFolder(&psfDesktop);
|
||||||
|
if(psfDesktop)
|
||||||
|
{
|
||||||
|
IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom);
|
||||||
|
IShellFolder_Release(psfDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (psfFrom)
|
||||||
|
{
|
||||||
|
/* get source and destination shellfolder */
|
||||||
|
ISFHelper *psfhlpdst, *psfhlpsrc;
|
||||||
|
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
|
||||||
|
IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (LPVOID*)&psfhlpsrc);
|
||||||
|
|
||||||
|
/* do the copy/move */
|
||||||
|
if (psfhlpdst && psfhlpsrc)
|
||||||
|
{
|
||||||
|
ISFHelper_CopyItems(psfhlpdst, psfFrom, lpcida->cidl, apidl);
|
||||||
|
/* fixme handle move
|
||||||
|
ISFHelper_DeleteItems(psfhlpsrc, lpcida->cidl, apidl);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
if(psfhlpdst) ISFHelper_Release(psfhlpdst);
|
||||||
|
if(psfhlpsrc) ISFHelper_Release(psfhlpsrc);
|
||||||
|
IShellFolder_Release(psfFrom);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ILFreeaPidl(apidl, lpcida->cidl);
|
||||||
|
SHFree(pidl);
|
||||||
|
|
||||||
|
/* release the medium*/
|
||||||
|
pReleaseStgMedium(&medium);
|
||||||
|
}
|
||||||
|
IDataObject_Release(pda);
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
HGLOBAL hMem;
|
||||||
|
|
||||||
|
OpenClipboard(NULL);
|
||||||
|
hMem = GetClipboardData(CF_HDROP);
|
||||||
|
|
||||||
|
if(hMem)
|
||||||
|
{
|
||||||
|
char * pDropFiles = (char *)GlobalLock(hMem);
|
||||||
|
if(pDropFiles)
|
||||||
|
{
|
||||||
|
int len, offset = sizeof(DROPFILESTRUCT);
|
||||||
|
|
||||||
|
while( pDropFiles[offset] != 0)
|
||||||
|
{
|
||||||
|
len = strlen(pDropFiles + offset);
|
||||||
|
TRACE("%s\n", pDropFiles + offset);
|
||||||
|
offset += len+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GlobalUnlock(hMem);
|
||||||
|
}
|
||||||
|
CloseClipboard();
|
||||||
|
#endif
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* ISVBgCm_fnInvokeCommand()
|
* ISVBgCm_fnInvokeCommand()
|
||||||
*/
|
*/
|
||||||
|
@ -157,38 +294,56 @@ static HRESULT WINAPI ISVBgCm_fnInvokeCommand(
|
||||||
TRACE("(%p)->(invcom=%p verb=%p wnd=%x)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd);
|
TRACE("(%p)->(invcom=%p verb=%p wnd=%x)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd);
|
||||||
|
|
||||||
/* get the active IShellView */
|
/* get the active IShellView */
|
||||||
lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0);
|
if((lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0)))
|
||||||
IShellBrowser_QueryActiveShellView(lpSB, &lpSV);
|
|
||||||
IShellView_GetWindow(lpSV, &hWndSV);
|
|
||||||
|
|
||||||
if(HIWORD(lpcmi->lpVerb))
|
|
||||||
{
|
{
|
||||||
TRACE("%s\n",lpcmi->lpVerb);
|
if(SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV)))
|
||||||
|
{
|
||||||
|
IShellView_GetWindow(lpSV, &hWndSV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! strcmp(lpcmi->lpVerb,CMDSTR_NEWFOLDERA))
|
if(lpSV)
|
||||||
|
{
|
||||||
|
if(HIWORD(lpcmi->lpVerb))
|
||||||
{
|
{
|
||||||
FIXME("%s not implemented\n",lpcmi->lpVerb);
|
TRACE("%s\n",lpcmi->lpVerb);
|
||||||
}
|
|
||||||
else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWLISTA))
|
if (! strcmp(lpcmi->lpVerb,CMDSTR_NEWFOLDERA))
|
||||||
{
|
{
|
||||||
SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW,0),0 );
|
if(lpSV) DoNewFolder(iface, lpSV);
|
||||||
}
|
}
|
||||||
else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWDETAILSA))
|
else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWLISTA))
|
||||||
{
|
{
|
||||||
SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW,0),0 );
|
if(hWndSV) SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW,0),0 );
|
||||||
|
}
|
||||||
|
else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWDETAILSA))
|
||||||
|
{
|
||||||
|
if(hWndSV) SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW,0),0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FIXME("please report: unknown verb %s\n",lpcmi->lpVerb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FIXME("please report: unknown verb %s\n",lpcmi->lpVerb);
|
switch(LOWORD(lpcmi->lpVerb))
|
||||||
|
{
|
||||||
|
case FCIDM_SHVIEW_NEWFOLDER:
|
||||||
|
DoNewFolder(iface, lpSV);
|
||||||
|
break;
|
||||||
|
case FCIDM_SHVIEW_INSERT:
|
||||||
|
DoPaste(iface);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* if it's a id just pass it to the parent shv */
|
||||||
|
SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0),0 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* if it's a id just pass it to the parent shv */
|
|
||||||
SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0),0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
IShellView_Release(lpSV); /* QueryActiveShellView does AddRef*/
|
IShellView_Release(lpSV); /* QueryActiveShellView does AddRef*/
|
||||||
|
}
|
||||||
return NOERROR;
|
return NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue