- 积分
- 43
- 明经币
- 个
- 注册时间
- 2014-7-5
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
如题,ObjectARX 2015怎么给CAD加主菜单。
因为2015的主菜单变了好多好多。。。之前一直用的2010,ObjectARX也是用的2010。
之前用这一段就可以了:
TRY
{
CAcadApplication IAcad;
CAcadMenuBar IMenuBar;
CAcadMenuGroups IMenuGroups;
CAcadMenuGroup IMenuGroup;
CAcadPopupMenus IPopUpMenus;
IAcad=acedGetAcadWinApp()->GetIDispatch(TRUE);
IMenuBar=IAcad.get_MenuBar();
long numberOfMenus;
numberOfMenus = IMenuBar.get_Count();
IMenuGroups=IAcad.get_MenuGroups();
VARIANT index;
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
IMenuGroup=IMenuGroups.Item(index);
IPopUpMenus=IMenuGroup.get_Menus();
CString cstrMenuName = _T("***");
VariantInit(&index);
V_VT(&index) = VT_BSTR;
V_BSTR(&index) = cstrMenuName.AllocSysString();
IDispatch* pDisp=NULL;
//see if the menu is already there
TRY{
pDisp = IPopUpMenus.Item(index); pDisp->AddRef();
}
CATCH(COleDispatchException,e){}
END_CATCH;
if (pDisp==NULL)
{
CAcadPopupMenu IPopUpMenu(IPopUpMenus.Add(cstrMenuName));
VariantInit(&index);
V_VT(&index)=VT_I4;
V_I4(&index)=0;
IPopUpMenu.AddMenuItem(index,_T("&***"),_T("_***"));
pDisp=IPopUpMenu.m_lpDispatch;
pDisp->AddRef();
}
CAcadPopupMenu IPopUpMenu(pDisp);
if(!IPopUpMenu.get_OnMenuBar())
{
VariantInit(&index);
V_VT(&index)=VT_I4;
V_I4(&index)=numberOfMenus-2;;
IPopUpMenu.InsertInMenuBar(index);
}
else
{
VariantInit(&index);
V_VT(&index)=VT_BSTR;
V_BSTR(&index)=cstrMenuName.AllocSysString();
IPopUpMenus.RemoveMenuFromMenuBar(index);
VariantClear(&index);
}
pDisp->Release();
}
CATCH (CMemoryException, e)
{
e->ReportError();
e->Delete();
}
END_CATCH
可是现在不行唉。。。一直都是依葫芦画瓢的,所以搞不懂是什么问题。
有大神能给个解决办法不?
|
|