如何在CAD中自己做一个菜单
本人在CAD的内嵌VBA环境中用窗体实现了某些功能,现在需要一个菜单和这个窗体关联,在选择菜单后调出该窗体,请问如何添加~~ <P>看看这个</P><P>Private Sub AddExtMenu()<BR> <BR> On Error Resume Next<BR> <BR> Dim CurrMenuGroup As AcadMenuGroup<BR> Dim menuPopupItem As AcadPopupMenuItem<BR> Dim newMenu As AcadPopupMenu<BR> Dim menuSp As AcadPopupMenuItem<BR> Dim menuErase As AcadPopupMenu<BR> <BR> Dim strMacro As String<BR> Dim macro As String<BR> <BR> Set CurrMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)<BR> Set newMenu = CurrMenuGroup.Menus.Add("编程(" & Chr(Asc("&")) & "P)")<BR> <BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape) & Chr(16) & "-vbarun" + Chr(32) & "ThisDrawing.setasInner" & Chr(32)<BR> strMacro = "内轮廓(" & Chr(Asc("&")) & "N)"<BR> Set menuPopupItem = newMenu.AddMenuItem(newMenu.count + 1, strMacro, macro)<BR> <BR> Set menuSp = newMenu.AddSeparator(newMenu.count + 1)<BR> <BR> Set menuErase = newMenu.AddSubMenu(newMenu.count + 1, "删除引线")<BR> <BR> '屏幕指定<BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape) & Chr(16) & "-vbarun" + Chr(32) & "ThisDrawing.EraseLeadLines" & Chr(32)<BR> strMacro = "选择(" & Chr(Asc("&")) & "S)"<BR> Set menuPopupItem = menuErase.AddMenuItem(menuErase.count + 1, strMacro, macro)<BR> <BR> '删除所有的引入引出线<BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape) & Chr(16) & "-vbarun" + Chr(32) & "ThisDrawing.EraseAllLeadLines" & Chr(32)<BR> strMacro = "全部(" & Chr(Asc("&")) & "E)"<BR> Set menuPopupItem = menuErase.AddMenuItem(newMenu.count + 1, strMacro, macro)<BR> <BR> Set menuSp = newMenu.AddSeparator(newMenu.count + 1)<BR> 'AutoPRO<BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape) & Chr(16) & "-vbarun" + Chr(32) & "ThisDrawing.Programing" & Chr(32)<BR> strMacro = "数控编程(" & Chr(Asc("&")) & "A)"<BR> Set menuPopupItem = newMenu.AddMenuItem(newMenu.count + 1, strMacro, macro)<BR> <BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape) & Chr(16) & "-vbarun" + Chr(32) & "ThisDrawing.Trial" & Chr(32)<BR> strMacro = "模拟切割(" & Chr(Asc("&")) & "T)"<BR> Set menuPopupItem = newMenu.AddMenuItem(newMenu.count + 1, strMacro, macro)<BR> 'menuPopupItem.Enable = False<BR> <BR> Set menuSp = newMenu.AddSeparator(newMenu.count + 1)<BR> <BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape) & Chr(16) & "-vbarun" + Chr(32) & "ThisDrawing.NC_DrawFile" & Chr(32)<BR> strMacro = "NC->图形(" & Chr(Asc("&")) & "D)"<BR> Set menuPopupItem = newMenu.AddMenuItem(newMenu.count + 1, strMacro, macro)<BR> <BR> Set menuSp = newMenu.AddSeparator(newMenu.count + 1)<BR> <BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape) & Chr(16) & "-vbarun" + Chr(32) & "ThisDrawing.About" & Chr(32)<BR> strMacro = "关于(" & Chr(Asc("&")) & "B)..."<BR> Set menuPopupItem = newMenu.AddMenuItem(newMenu.count + 1, strMacro, macro)<BR> <BR> '显示菜单<BR> newMenu.InsertInMenuBar ThisDrawing.Application.MenuBar.count - 1<BR> <BR> '释放对象<BR> Set menuSp = Nothing<BR> Set CurrMenuGroup = Nothing<BR> Set newMenu = Nothing<BR> Set menuPopupItem = Nothing<BR> Set menuErase = Nothing<BR> <BR>End Sub<BR></P> userform.show <P>多谢多谢啊~~~~</P>
页:
[1]