- 积分
- 12459
- 明经币
- 个
- 注册时间
- 2003-5-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-9-26 16:15:00
|
显示全部楼层
回复
Public Sub test()
Dim myMenuName As String myMenuName = "软件"
'-------------------------------------------------------- Dim currMenuGroups As AcadMenuGroups Set currMenuGroups = ThisDrawing.Application.MenuGroups Dim currMenuGroup As AcadMenuGroup Dim i As Integer Dim strMenuGrpName As String For i = 0 To currMenuGroups.Count - 1 Set currMenuGroup = currMenuGroups.Item(i) strMenuGrpName = currMenuGroup.Name MsgBox strMenuGrpName If StrComp(strMenuGrpName, "ACAD", vbTextCompare) = 0 Then Dim popMenus As AcadPopupMenus Set popMenus = currMenuGroup.Menus Dim popMenu As AcadPopupMenu Dim bExist As Boolean bExist = False Dim strMenuName As String Dim j As Integer For j = 0 To popMenus.Count - 1 Set popMenu = popMenus.Item(j) strMenuName = popMenu.Name If StrComp(strMenuName, myMenuName, vbTextCompare) = 0 Then ' If popMenu.OnMenuBar = True Then ' popMenus.RemoveMenuFromMenuBar (myMenuName) ' End If bExist = True Exit For End If Next If bExist = False Then ' Create the new menu Dim newMenu As AcadPopupMenu Set newMenu = currMenuGroup.Menus.Add(myMenuName) ' Add a menu item to the new menu Dim newMenuItem As AcadPopupMenuItem Dim openMacro As String ' Assign the macro string the VB equivalent of "ESC ESC _open " openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32) Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "Open", openMacro) ' Display the menu on the menu bar popMenus.InsertMenuInMenuBar myMenuName, "" End If Exit For End If Next
End Sub
现在不会有你说的问题了,但是有些疑问,
popMenus.RemoveMenuFromMenuBar (myMenuName)不能彻底移除一个popMenu. |
|