CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2023 开发者帮助

AttachToolbarToFlyout 方法 (ActiveX)

2024-5-18 18:55| 发布者: admin| 查看: 73| 评论: 0|原作者: admin|来自: AutoCAD

AttachToolbarToFlyout 方法 (ActiveX)

将工具栏附加到定义为浮出控件的工具栏按钮。

支持的平台:仅限 Windows

签名

VBA:

object.AttachToolbarToFlyout MenuGroupName, ToolbarName
对象

类型:ToolbarItem

此方法应用到的对象。

MenuGroup名称

访问:仅输入

类型:字符串

包含要附加的工具栏的菜单组的名称。

工具栏名称

访问:仅输入

类型:字符串

要附加的工具栏的名称。

返回值 (RetVal)

无返回值。

言论

若要将新按钮创建为浮出控件,请使用该方法并将 FlyoutButton 参数设置为 。将按钮创建为浮出控件按钮后,可以使用该方法将浮出控件工具栏附加到该按钮。AddToolBarButtonTrueAttachToolbarToFlyout

若要查询工具栏按钮以查看它是否为浮出控件按钮,请使用该属性。若要查找附加到浮出控件工具栏按钮的工具栏,请使用该属性。TypeFlyout

例子

VBA:

Sub Example_AttachToolbarToFlyout()
    ' This example uses MenuGroups to obtain a reference to the AutoCAD main menu.
    ' It then creates a new Toolbar(TestMenu) with a Toolbar button that will act
    ' as a flyout.  It then sets the Flyout menu to an existing Toolbar menu.
    ' The Toolbar will automatically be displayed and will display the UCS menu
    ' as a flyout.
        
    Dim currMenuGroup As acadMenuGroup
    Dim newToolBar As AcadToolbar, newToolBarFlyoutButton As AcadToolbarItem
    
    On Error GoTo ERRORTRAP
    
    ' Use MenuGroups property to obtain reference to main AutoCAD menu
    Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("ACAD")
    
    ' Create a new Toolbar in this group
    Set newToolBar = currMenuGroup.Toolbars.Add("TestMenu")
    
    ' Add new button to TestMenu that will link to the Flyout menu
    '
    ' * NOTE: Set the macro name to the name of the flyout toolbar because
    ' setting it to an empty string causes an error.  The paremeter
    ' is actually ignored when the style is flyout, but must have any value other than "".
    Set newToolBarFlyoutButton = newToolBar.AddToolbarButton(newToolBar.count + 1, "Flyout", "Flyout", "UCS", True)
    
    ' Link the existing toolbar "UCS" as the flyout for the new toolbar button
    '
    ' * NOTE: To change the flyout, simply change the MenuGroup and Toolbar name below
    newToolBarFlyoutButton.AttachToolbarToFlyout "ACAD", "UCS"
   
    MsgBox "A new Toolbar with a flyout has been added to the AutoCAD menu system!"
    
    Exit Sub

ERRORTRAP:
    MsgBox "The following error has occurred: " & Err.Description
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_AttachToolbarToFlyout()
    ;; This example uses MenuGroups to obtain a reference to the AutoCAD main menu.
    ;; It then creates a new Toolbar(TestMenu) with a Toolbar button that will act
    ;; as a flyout.  It then sets the Flyout menu to an existing Toolbar menu.
    ;; The Toolbar will automatically be displayed and will display the UCS menu
    ;; as a flyout.
    (setq acadObj (vlax-get-acad-object))
    (setq currMenuGroup (vla-Item (vla-get-MenuGroups acadObj) 0))
      
    ;; Create a new Toolbar in this group
    (setq newToolBar (vla-Add (vla-get-Toolbars currMenuGroup) "TestMenu"))
    
    ;; Add new button to TestMenu that will link to the Flyout menu
    ;;
    ;; * NOTE: Set the macro name to the name of the flyout toolbar because
    ;; setting it to an empty string causes an error.  The paremeter
    ;; is actually ignored when the style is flyout, but must have any value other than "".
    (setq newToolBarFlyoutButton (vla-AddToolbarButton newToolBar (1+ (vla-get-Count newToolBar)) "Flyout" "Flyout" "UCS" :vlax-true))
    
    ;; Link the existing toolbar "UCS" as the flyout for the new toolbar button
    ;;
    ;; * NOTE: To change the flyout, simply change the MenuGroup and Toolbar name below
    (vla-AttachToolbarToFlyout newToolBarFlyoutButton "ACAD" "UCS")
   
    (alert "A new Toolbar with a flyout has been added to the AutoCAD menu system!")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 22:30

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部