AnsweredAssumed Answered

Setting icon lists in CreateFlyoutGroup2 (C++)

Question asked by Matthew Scarpino on Apr 6, 2018

The CreateFlyoutGroup2 function requires two lists of icon paths as variants. The following code compiles, but it causes SolidWorks to crash:


CComVariant mainIconList;

mainIconList.vt = VT_ARRAY | VT_BSTR;


CComSafeArray<BSTR> mainIconArray(3);

mainIconArray[0] = main_20_20;

mainIconArray[1] = main_32_32;

mainIconArray[2] = main_40_40;

mainIconList.parray = mainIconArray.m_psa;


CComVariant iconList;


iconList.vt = VT_ARRAY | VT_BSTR;

CComSafeArray<BSTR> iconArray(3);

iconArray[0] = icon_20_20;

iconArray[1] = icon_32_32;

iconArray[2] = icon_40_40;

iconList.parray = iconArray.m_psa;


iCmdMgr->CreateFlyoutGroup2(FLYOUT_ID, flyoutName, flyoutTip, flyoutTip, mainIconList, iconList, flyoutCallback, flyoutEnable, &iFlyGrp);


Is there a way to fix this? I can't find any example C++ code that calls CreateFlyoutGroup2.