#include <string.h>
+#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
+
#include "winerror.h"
#include "wine/debug.h"
* IContextMenu Implementation
*/
typedef struct
-{ ICOM_VFIELD(IContextMenu2);
+{ IContextMenu2Vtbl *lpVtbl;
DWORD ref;
IShellFolder* pSFParent;
LPITEMIDLIST pidl; /* root pidl */
} ItemCmImpl;
-static struct ICOM_VTABLE(IContextMenu2) cmvt;
+static struct IContextMenu2Vtbl cmvt;
/**************************************************************************
* ISvItemCm_CanRenameItems()
{ ItemCmImpl* cm;
UINT u;
- cm = (ItemCmImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ItemCmImpl));
+ cm = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ItemCmImpl));
cm->lpVtbl = &cmvt;
cm->ref = 1;
cm->pidl = ILClone(pidl);
*/
static HRESULT WINAPI ISvItemCm_fnQueryInterface(IContextMenu2 *iface, REFIID riid, LPVOID *ppvObj)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
*/
static ULONG WINAPI ISvItemCm_fnAddRef(IContextMenu2 *iface)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
+ ULONG refCount = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(count=%lu)\n",This, This->ref);
+ TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
- return ++(This->ref);
+ return refCount;
}
/**************************************************************************
*/
static ULONG WINAPI ISvItemCm_fnRelease(IContextMenu2 *iface)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
+ ULONG refCount = InterlockedDecrement(&This->ref);
- TRACE("(%p)->()\n",This);
+ TRACE("(%p)->(count=%li)\n", This, refCount + 1);
- if (!--(This->ref))
+ if (!refCount)
{
TRACE(" destroying IContextMenu(%p)\n",This);
_ILFreeaPidl(This->apidl, This->cidl);
HeapFree(GetProcessHeap(),0,This);
- return 0;
}
- return This->ref;
+ return refCount;
}
/**************************************************************************
UINT idCmdLast,
UINT uFlags)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",This, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
_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);
+ }
+
+ _InsertMenuItem(hmenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
+ _InsertMenuItem(hmenu, indexMenu++, TRUE, FCIDM_SHVIEW_PROPERTIES, MFT_STRING, "&Properties::", MFS_ENABLED);
+
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (FCIDM_SHVIEWLAST));
}
HWND hwnd,
LPCSTR verb)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
UINT i, bFolderFound = FALSE;
LPITEMIDLIST pidlFQ;
IContextMenu2 *iface,
HWND hwnd)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
LPSHELLBROWSER lpSB;
LPSHELLVIEW lpSV;
*/
static void DoDelete(IContextMenu2 *iface)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
ISFHelper * psfhlp;
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlp);
HWND hwnd,
BOOL bCut)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
LPSHELLBROWSER lpSB;
LPSHELLVIEW lpSV;
TRACE("(%p)->(wnd=%p,bCut=0x%08x)\n",This, hwnd, bCut);
- if(GetShellOle())
+ /* get the active IShellView */
+ if ((lpSB = (LPSHELLBROWSER)SendMessageA(hwnd, CWM_GETISHELLBROWSER,0,0)))
{
- /* get the active IShellView */
- if ((lpSB = (LPSHELLBROWSER)SendMessageA(hwnd, CWM_GETISHELLBROWSER,0,0)))
+ if (SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV)))
{
- if (SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV)))
+ if (SUCCEEDED(IShellView_GetItemObject(lpSV, SVGIO_SELECTION, &IID_IDataObject, (LPVOID*)&lpDo)))
{
- if (SUCCEEDED(IShellView_GetItemObject(lpSV, SVGIO_SELECTION, &IID_IDataObject, (LPVOID*)&lpDo)))
- {
- pOleSetClipboard(lpDo);
- IDataObject_Release(lpDo);
- }
- IShellView_Release(lpSV);
+ OleSetClipboard(lpDo);
+ IDataObject_Release(lpDo);
}
+ IShellView_Release(lpSV);
}
}
return TRUE;
-#if 0
-/*
- the following code does the copy operation witout ole32.dll
- we might need this possibility too (js)
-*/
- BOOL bSuccess = FALSE;
-
- TRACE("(%p)\n", iface);
-
- if(OpenClipboard(NULL))
- {
- if(EmptyClipboard())
- {
- IPersistFolder2 * ppf2;
- IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
- if (ppf2)
- {
- LPITEMIDLIST pidl;
- IPersistFolder2_GetCurFolder(ppf2, &pidl);
- if(pidl)
- {
- HGLOBAL hMem;
-
- hMem = RenderHDROP(pidl, This->apidl, This->cidl);
-
- if(SetClipboardData(CF_HDROP, hMem))
- {
- bSuccess = TRUE;
- }
- SHFree(pidl);
- }
- IPersistFolder2_Release(ppf2);
- }
-
- }
- CloseClipboard();
- }
- return bSuccess;
-#endif
}
/**************************************************************************
* ISvItemCm_fnInvokeCommand()
IContextMenu2 *iface,
LPCMINVOKECOMMANDINFO lpcmi)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
if (lpcmi->cbSize != sizeof(CMINVOKECOMMANDINFO))
FIXME("Is an EX structure\n");
TRACE("Verb FCIDM_SHVIEW_CUT\n");
DoCopyOrCut(iface, lpcmi->hwnd, TRUE);
break;
+ case FCIDM_SHVIEW_PROPERTIES:
+ TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n");
+ /* Open the property sheet page */
+ SHObjectProperties(NULL, TEXT("SHOP_FILEPATH"), lpcmi->hwnd, NULL);
+ break;
default:
FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb));
}
LPSTR lpszName,
UINT uMaxNameLen)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
HRESULT hr = E_INVALIDARG;
WPARAM wParam,
LPARAM lParam)
{
- ICOM_THIS(ItemCmImpl, iface);
+ ItemCmImpl *This = (ItemCmImpl *)iface;
TRACE("(%p)->(msg=%x wp=%x lp=%lx)\n",This, uMsg, wParam, lParam);
return E_NOTIMPL;
}
-static struct ICOM_VTABLE(IContextMenu2) cmvt =
+static struct IContextMenu2Vtbl cmvt =
{
- ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ISvItemCm_fnQueryInterface,
ISvItemCm_fnAddRef,
ISvItemCm_fnRelease,