关于浏览菜单项的属性 (VBA/ActiveX)
使用对象的属性,可以控制对象在对象上的显示和行为方式。PopupMenuItemPopupMenu 所有菜单项共享以下属性:
启用和禁用菜单项此示例创建一个名为“TestMenu”的新菜单,并插入两个菜单项。然后使用该属性禁用第二个菜单项,并且该菜单将显示在菜单栏上。Enable Sub Ch6_DisableMenuItem() Dim currMenuGroup As AcadMenuGroup Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0) ' Create the new menu Dim newMenu As AcadPopupMenu Set newMenu = currMenuGroup.Menus.Add("TestMenu") ' Add two menu items and a menu separator to the new menu Dim MenuEnable As AcadPopupMenuItem Dim MenuDisable As AcadPopupMenuItem Dim MenuSeparator As AcadPopupMenuItem Dim openMacro As String ' Assign the macro the VB equivalent of "ESC ESC _open " openMacro = Chr(3) + Chr(3) + "_open " Set MenuEnable = newMenu.AddMenuItem _ (newMenu.count + 1, "OpenEnabled", openMacro) Set MenuSeparator = newMenu.AddSeparator("") Set MenuDisable = newMenu.AddMenuItem _ (newMenu.count + 1, "OpenDisabled", openMacro) ' Disable the second menu item MenuDisable.Enable = False ' Display the menu on the menu bar newMenu.InsertInMenuBar _ (ThisDrawing.Application.menuBar.count + 1) End Sub 相关概念 |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 11:36
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.