关于创建浮出控件工具栏 (VBA/ActiveX)
若要将浮出控件工具栏按钮添加到工具栏,请使用该方法。此方法创建一个新对象并将其添加到指定的工具栏中。AddToolbarButtonToolbarItem 该方法采用五个参数作为输入:Index、Name、HelpString、Macro 和 FlyoutButton。通过将 FlyoutButton 参数设置为 TRUE,新按钮将创建为浮出控件按钮。此方法的返回值将是新的浮出控件工具栏。然后,可以像普通工具栏一样填充浮出控件工具栏。AddToolbarButton 创建浮出控件工具栏按钮本示例创建两个工具栏。第一个工具栏包含浮出控件按钮。第二个工具栏附加到第一个工具栏上的浮出控件按钮。 Sub Ch6_AddFlyoutButton() Dim currMenuGroup As AcadMenuGroup Set currMenuGroup = ThisDrawing.Application. _ MenuGroups.Item(0) ' Create the first toolbar Dim FirstToolbar As AcadToolbar Set FirstToolbar = currMenuGroup.Toolbars. _ Add("FirstToolbar") ' Add a flyout button to the first menu on the menu bar Dim FlyoutButton As AcadToolbarItem Set FlyoutButton = FirstToolbar.AddToolbarButton _ ("", "Flyout", "Demonstrates a flyout button", _ "OPEN", True) ' Create the second toolbar. This will be attached to ' the first toolbar through the flyout button. Dim SecondToolbar As AcadToolbar Set SecondToolbar = currMenuGroup.Toolbars. _ Add("SecondToolbar") ' Add a button to the next toolbar Dim newButton As AcadToolbarItem Dim openMacro As String ' Assign the macro the VB equivalent of "ESC ESC _open " openMacro = Chr(3) + Chr(3) + "_open " Set newButton = SecondToolbar.AddToolbarButton _ ("", "NewButton", "Open a file.", openMacro) ' Attach the second toolbar to the flyout ' button on the first toolbar FlyoutButton.AttachToolbarToFlyout currMenuGroup.Name, _ SecondToolbar.Name ' Display the first toolbar, hide the second toolbar FirstToolbar.Visible = True SecondToolbar.Visible = False End Sub |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 12:51
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.