Creación de barras de herramientas desplegables
From AutoCAD ActiveX
Para añadir un botón desplegable a una barra de herramientas, utilice el método AddToolbarButton. Este método crea un objeto ToolbarItem nuevo y lo añade a la barra de herramientas indicada.
El método AddToolbarButton requiere cinco parámetros de entrada: Index, Name, HelpString, Macro y FlyoutButton. Al asignar el valor TRUE al parámetro FlyoutButton, el nuevo botón se crea como un icono desplegable. El valor que devuelva este método será la nueva barra de herramientas desplegable, que podrá rellenarse como cualquier barra de herramientas normal.
Para obtener más información acerca de cómo rellenar una barra de herramientas, véase Adición de botones nuevos a una barra de herramientas.
Creación de un botón desplegable para barras de herramientas
Este ejemplo crea dos barras de herramientas. La primera contiene un botón desplegable. La segunda está enlazada con el botón desplegable de la primera.
Sub Ch6_AddFlyoutButton()
Dim currMenuGroup As AcadMenuGroup
Set currMenuGroup = ThisDrawing.Application. _
MenuGroups.Item(0)
' Create the first toolbarDim FirstToolbar As AcadToolbarSet FirstToolbar = currMenuGroup.Toolbars. _Add("FirstToolbar")' Add a flyout button to the first menu on the menu barDim FlyoutButton As AcadToolbarItemSet FlyoutButton = FirstToolbar.AddToolbarButton _("", "Flyout", "Demonstrates a flyout button", _"OPEN", True)' Create the second toolbar. This will be attached to' the first toolbar via the flyout button.Dim msg As StringSet SecondToolbar = currMenuGroup.Toolbars. _Add("SecondToolbar")' Add a button to the next toolbarDim newButton As AcadToolbarItemDim 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 toolbarFlyoutButton.AttachToolbarToFlyout currMenuGroup.Name, _SecondToolbar.Name' Display the first toolbar, hide the second toolbarFirstToolbar.Visible = TrueSecondToolbar.Visible = FalseEnd Sub