static HRESULT STDMETHODCALLTYPE ITrayBandSiteImpl_AddContextMenus(IN OUT ITrayBandSite *iface, IN HMENU hmenu, IN UINT indexMenu, IN UINT idCmdFirst, IN UINT idCmdLast, IN UINT uFlags, OUT IContextMenu **ppcm) { ITrayBandSiteImpl *This = ITrayBandSiteImpl_from_ITrayBandSite(iface); IShellService *pSs; HRESULT hRet; if (This->ContextMenu == NULL) { /* Cache the context menu so we don't need to CoCreateInstance all the time... */ hRet = CoCreateInstance(&CLSID_IShellBandSiteMenu, NULL, CLSCTX_INPROC_SERVER, &IID_IShellService, (PVOID*)&pSs); DbgPrint("CoCreateInstance(CLSID_IShellBandSiteMenu) for IShellService returned: 0x%x\n", hRet); if (!SUCCEEDED(hRet)) return hRet; hRet = IShellService_SetOwner(pSs, IUnknown_from_ITrayBandSiteImpl(This)); if (!SUCCEEDED(hRet)) { IShellService_Release(pSs); return hRet; } hRet = IShellService_QueryInterface(pSs, &IID_IContextMenu, (PVOID*)&This->ContextMenu); IShellService_Release(pSs); if (!SUCCEEDED(hRet)) return hRet; } if (ppcm != NULL) { IContextMenu_AddRef(This->ContextMenu); *ppcm = This->ContextMenu; } /* Add the menu items */ return IContextMenu_QueryContextMenu(This->ContextMenu, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags); }
static HRESULT WINAPI CompositeCMenu_QueryContextMenu(IContextMenu3 *iface, HMENU hmenu,UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { CompositeCMenu *This = impl_from_IContextMenu3(iface); UINT i=0; UINT id_offset=idCmdFirst; TRACE("(%p)->(%p,%u,%u,%u,%x)\n",iface,hmenu,indexMenu,idCmdFirst,idCmdLast,uFlags); for(;i<This->menu_count;i++) { HRESULT hres; This->offsets[i]=id_offset; hres = IContextMenu_QueryContextMenu(This->menus[i],hmenu,indexMenu,id_offset,idCmdLast,uFlags); if(SUCCEEDED(hres)) id_offset+=hres; } return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, id_offset-idCmdFirst); }