SUBMENU request C++ snipit to create a AddPopup(pSubMenu ) to Ribbion Panel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CPK Add popups here
// I'm trying to use AddButtonPopup in VC++, but I couldn't find any example code. The code below
// is converted from the sample given in visual basic, but I think the parameter obEnum, passed as
// const VARIANT &ObjectsEnumerator is not configured correctly. The VB code does this automatically.
// When I run this under the debugger it fails during the call to CreateObjectCollection.
// Can you point out what is wrong, or point me to sample code in VC++ that works?
/*CComPtr<ObjectCollection> pObCol;
VARIANT obEnum;
obEnum.vt=VT_DISPATCH;
//Create Collection object
VARIANT vopt;
VariantInit(&vopt);
V_VT(&vopt) = VT_ERROR;
vopt.scode = DISP_E_PARAMNOTFOUND;
hr = m_pApplication->TransientObjects->CreateObjectCollection(vopt,&pObCol);
if (FAILED(hr)) return hr;
CComPtr<ButtonDefinitionObject> pBut1;
hr=m_pCmd1->GetButtonDefinition(&pBut1);
if (FAILED(hr)) return hr;
hr=pObCol->Add(pBut1);
if (FAILED(hr)) return hr;
CComPtr<CommandControl> pPopup2DCtrl;
hr=pPartCustUIRibbonPanelCtrls->AddButtonPopup(pObCol, VARIANT_TRUE, VARIANT_TRUE,
CComBSTR(_T("Autodesk:ReverseEngineering:PopupPanel2D")), VARIANT_FALSE, &pPopup2DCtrl);
if (FAILED(hr)) return hr;
pPopup2DCtrl->DisplayedControl = pPopup2DCtrl->ControlDefinition;
*/ // Solution
//To create a popup menu it is necessary to start with CommandBar of kPopUpCommandBar type:
//UserInterfaceManager uiMgr = _application.UserInterfaceManager;
//m_pApplication->UserInterfaceManager;