예제 #1
0
파일: shlmenu.c 프로젝트: AlexSteel/wine
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);
}
예제 #2
0
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);
}