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:
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:
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: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!