Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

ArcObjects (C++) failing to add IMultiItem to custom toolbar

$
0
0
I have a custom Toolbar. To this I want to add a Menu, MyMenu, with some items.
I have implemented IMultiItem to return the items:
Code:

class CMyItems :
        ...
        public IMultiItem
        ...
STDMETHOD(OnPopup)(LPDISPATCH Hook, long * ItemCount)
{
        m_ipApp = Hook;
        *ItemCount = 2;
        return S_OK;
}
STDMETHOD(get_ItemCaption)(long index, BSTR * itemName)
{
        if(index == 0)
                *itemName = ::SysAllocString(L"MyItem1");
        else if(index == 1)
                *itemName = ::SysAllocString(L"MyItem2");
        return S_OK;
};

I have a the following menu class:
Code:

class CMyMenu :
        ...
        public ICommand,
        public IMenuDef
        ...
        STDMETHOD(get_ItemCount)(long * numItems)
        {
                *numItems = 1;
                return S_OK;
        }
        STDMETHOD(GetItemInfo)(long pos, IItemDef * itemDef)
        {
                // CLSID of CMyItems:
                itemDef->put_ID(L"{2B5842E2-B14C-463E-9733-5BFF271C9BEF}");
                itemDef->put_SubType(1);
                return S_OK;
        }
};

I add this to my toolbar:
Code:

STDMETHOD(GetItemInfo)(long pos, IItemDef * itemDef)
{
    if (itemDef == NULL)
        return E_POINTER;

    if (pos == 0) {
        itemDef->put_Group (VARIANT_FALSE);
        // CLSID of CMyMenu
        HRESULT hr = itemDef->put_ID(CComBSTR(L"{96A2B223-BF0D-410C-B22B-892FED3D9A15}"));
        if (FAILED (hr)) {
            return hr;
        }
      }
}

When I start ArcScene; I see CMyMenu on my toolbar but it is empty!

Viewing all articles
Browse latest Browse all 1374

Trending Articles