easypower 发表于 2009-2-10 12:22:00
<p>1.profiles</p><p>2.com方式产生</p>庞琛虹 发表于 2009-2-10 20:49:00
开发文档中好像有个例子的啊unionsoft 发表于 2009-2-12 13:21:00
可以在Arx直接调用命令'menu'来加载,这样当Arx加载时,菜单也加载了。<br/>当然之前要将对话框模式关闭: filedia=0gentlerain 发表于 2009-4-11 09:56:00
<p> static void HxjMenuCom_AddMenu(void)<br/> {<br/> // Add your code for command HxjMenuCom._AddMenu here<br/> TRY<br/> {<br/> CAcadApplication IAcad(acedGetAcadWinApp()->GetIDispatch(TRUE));<br/> CAcadMenuBar IMenuBar(IAcad.get_MenuBar());<br/> long numberOfMenus;<br/> numberOfMenus=IMenuBar.get_Count();<br/> CAcadMenuGroups IMenuGroups(IAcad.get_MenuGroups());<br/> VARIANT index;<br/> VariantInit(&index);<br/> V_VT(&index)=VT_I4;<br/> V_I4(&index)=0;<br/> CAcadMenuGroup IMenuGroup(IMenuGroups.Item(index));<br/> CAcadPopupMenus IPopUpMenus(IMenuGroup.get_Menus());<br/> CString cstrMenuName="总图(&Z)";<br/> VariantInit(&index);<br/> V_VT(&index)=VT_BSTR;<br/> V_BSTR(&index)=cstrMenuName.AllocSysString();<br/> IDispatch* pDisp=NULL;<br/> //see if the menu is already there<br/> TRY<br/> {<br/> pDisp=IPopUpMenus.Item(index);<br/> pDisp->AddRef();<br/> }<br/> CATCH(COleDispatchException,e)<br/> {</p><p> }<br/> END_CATCH;<br/> if(pDisp==NULL)<br/> {<br/> //create it<br/> CAcadPopupMenu IPopUpMenu(IPopUpMenus.Add(cstrMenuName));<br/> VariantInit(&index);<br/> V_VT(&index)=VT_I4;<br/> V_I4(&index)=0;<br/> IPopUpMenu.AddMenuItem(index,"直线(&L)","_Line ");<br/> ///////////////////<br/> VariantInit(&index);<br/> V_VT(&index)=VT_I4;<br/> V_I4(&index)=1;<br/> IPopUpMenu.AddSeparator(index);<br/> ///////////////////<br/> VariantInit(&index);<br/> V_VT(&index)=VT_I4;<br/> V_I4(&index)=2;<br/> IPopUpMenu.AddMenuItem(index,"圆(&C)","_Circle ");</p><p> pDisp=IPopUpMenu.m_lpDispatch;<br/> pDisp->AddRef();<br/> }</p><p> CAcadPopupMenu IPopUpMenu(pDisp);<br/> if(!IPopUpMenu.get_OnMenuBar())<br/> {<br/> VariantInit(&index);<br/> V_VT(&index)=VT_I4;<br/> V_I4(&index)=numberOfMenus-2;<br/> IPopUpMenu.InsertInMenuBar(index);<br/> }<br/> else<br/> {<br/> VariantInit(&index);<br/> V_VT(&index)=VT_BSTR;<br/> V_BSTR(&index)=cstrMenuName.AllocSysString();<br/> IPopUpMenus.RemoveMenuFromMenuBar(index);<br/> VariantClear(&index);<br/> }<br/> pDisp->Release();<br/> }<br/> CATCH(COleDispatchException,e)<br/> {<br/> e->ReportError();<br/> e->Delete();<br/> }<br/> END_CATCH;<br/> }</p><p></p><p>稍微改一下就可以变为自动了,经过调试可以运行</p>松竹 发表于 2009-4-12 22:45:00
<p>不知是想使用代码的方式动态添加菜单还是使用mnu文件的方式添加菜单,如果使用代码的方式添加菜单需要使用AutoCAD的com接口来实现。参考下面的代码:</p><p>void TdiFoundationApp::CreateMenuItem()<br/>{<br/> TRY<br/> {<br/> IAcadApplication IAcad(acedGetAcadWinApp()->GetIDispatch(TRUE));</p><p> IAcadMenuBar IMenuBar(IAcad.GetMenuBar());</p><p> long numberOfMenus;<br/> numberOfMenus = IMenuBar.GetCount();</p><p> IAcadMenuGroups IMenuGroups(IAcad.GetMenuGroups());</p><p> VARIANT index;<br/> VariantInit(&index);<br/> V_VT(&index) = VT_I4;<br/> V_I4(&index) = 0;</p><p> IAcadMenuGroup IMenuGroup(IMenuGroups.Item(index));</p><p> IAcadPopupMenus IPopUpMenus(IMenuGroup.GetMenus());</p><p> CString cstrMenuName = _T("TDI");</p><p> VariantInit(&index);<br/> V_VT(&index) = VT_BSTR;<br/> V_BSTR(&index) = cstrMenuName.AllocSysString();</p><p> IDispatch* pDisp=NULL;</p><p> //see if the menu is already there<br/> TRY<br/> {<br/> pDisp = IPopUpMenus.Item(index);<br/> pDisp->AddRef();<br/> }<br/> CATCH(COleDispatchException,e)<br/> {}<br/> END_CATCH;</p><p> int iIndex = 0;<br/> if (pDisp==NULL)<br/> {<br/> //create it<br/> IAcadPopupMenu IPopUpMenu(IPopUpMenus.Add(cstrMenuName));</p><p> VariantInit(&index);<br/> V_VT(&index) = VT_I4;<br/> V_I4(&index) = iIndex++;<br/> IPopUpMenu.AddMenuItem(index, _T("新建(&N)"), _T("_MyNEW "));</p><p> VariantInit(&index);<br/> V_VT(&index) = VT_I4;<br/> V_I4(&index) = iIndex++;<br/> IPopUpMenu.AddMenuItem(index, _T("检入(&I)"), _T("_MyCHECKIN "));</p><p><br/> pDisp = IPopUpMenu.m_lpDispatch;<br/> pDisp->AddRef();<br/> }</p><p> IAcadPopupMenu IPopUpMenu(pDisp);<br/> if (!IPopUpMenu.GetOnMenuBar())<br/> {<br/> VariantInit(&index);<br/> V_VT(&index) = VT_I4;<br/> V_I4(&index) = numberOfMenus - 2;;<br/> IPopUpMenu.InsertInMenuBar(index);<br/> }<br/> else<br/> {<br/> VariantInit(&index);<br/> V_VT(&index) = VT_BSTR;<br/> V_BSTR(&index) = cstrMenuName.AllocSysString();<br/> IPopUpMenus.RemoveMenuFromMenuBar(index);<br/> VariantClear(&index);<br/> }<br/> pDisp->Release();<br/> }<br/> CATCH(COleDispatchException,e)<br/> {<br/> e->ReportError();<br/> e->Delete();<br/> }<br/> END_CATCH;<br/>}</p>nogirlfriend 发表于 2009-4-22 21:08:00
<p>利用COM接口来实现相关autocad菜单的扩展。。。。</p>nogirlfriend 发表于 2009-4-23 18:10:00
<p>利用Com来做吧 </p><p>具体见例子:\samples\com\AsdkMfcComSamp_dg</p><p></p>
页:
1
[2]