HRESULT BackgroundMenu_Constructor(IShellFolder *parent, BOOL desktop, REFIID riid, void **pObj) { ContextMenu *This; HRESULT hr; This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); if (!This) return E_OUTOFMEMORY; This->IContextMenu3_iface.lpVtbl = &BackgroundContextMenuVtbl; This->ref = 1; This->parent = parent; This->pidl = NULL; This->apidl = NULL; This->cidl = 0; This->allvalues = FALSE; This->desktop = desktop; if (parent) IShellFolder_AddRef(parent); hr = IContextMenu3_QueryInterface(&This->IContextMenu3_iface, riid, pObj); IContextMenu3_Release(&This->IContextMenu3_iface); return hr; }
static HRESULT CompositeCMenu_Constructor(IContextMenu **menus,UINT menu_count, REFIID riid, void **ppv) { CompositeCMenu *ret = HeapAlloc(GetProcessHeap(),0,sizeof(CompositeCMenu)); UINT i; TRACE("(%p,%u,%s,%p)\n",menus,menu_count,shdebugstr_guid(riid),ppv); if(!ret) return E_OUTOFMEMORY; ret->IContextMenu3_iface.lpVtbl = &CompositeCMenuVtbl; ret->menu_count = menu_count; ret->menus = HeapAlloc(GetProcessHeap(),0,menu_count*sizeof(IContextMenu*)); if(!ret->menus) { HeapFree(GetProcessHeap(),0,ret); return E_OUTOFMEMORY; } ret->offsets = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,menu_count*sizeof(UINT)); if(!ret->offsets) { HeapFree(GetProcessHeap(),0,ret->menus); HeapFree(GetProcessHeap(),0,ret); return E_OUTOFMEMORY; } ret->refCount=0; memcpy(ret->menus,menus,menu_count*sizeof(IContextMenu*)); for(i=0;i<menu_count;i++) IContextMenu_AddRef(menus[i]); return IContextMenu3_QueryInterface(&(ret->IContextMenu3_iface),riid,ppv); }
HRESULT ItemMenu_Constructor(IShellFolder *parent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *apidl, UINT cidl, REFIID riid, void **pObj) { ContextMenu* This; HRESULT hr; UINT i; This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); if (!This) return E_OUTOFMEMORY; This->IContextMenu3_iface.lpVtbl = &ItemContextMenuVtbl; This->ref = 1; This->parent = parent; if (parent) IShellFolder_AddRef(parent); This->pidl = ILClone(pidl); This->apidl = _ILCopyaPidl(apidl, cidl); This->cidl = cidl; This->allvalues = TRUE; This->desktop = FALSE; for (i = 0; i < cidl; i++) This->allvalues &= (_ILIsValue(apidl[i]) ? 1 : 0); hr = IContextMenu3_QueryInterface(&This->IContextMenu3_iface, riid, pObj); IContextMenu3_Release(&This->IContextMenu3_iface); return hr; }