AddToolbarButton 方法 (ActiveX)
将工具栏项添加到工具栏的指定位置。 支持的平台:仅限 Windows 签名VBA: RetVal = object.AddToolbarButton(Index, Name, HelpString, Macro [, FlyoutButton])
言论只有当工具栏可见时,才能添加或删除工具栏按钮。 例子VBA: Sub Example_AddToolbarButton()
' This example creates a new toolbar called TestToolbar and inserts a
' toolbar button into it. The toolbar is then displayed.
' To remove the toolbar after execution of this macro, use the Customize Menu
' option from the Tools menu.
Dim currMenuGroup As acadMenuGroup
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' Create the new toolbar
Dim newToolBar As AcadToolbar
Set newToolBar = currMenuGroup.Toolbars.Add("TestToolbar")
' Add a button to the new toolbar
Dim newButton As AcadToolbarItem
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 newButton = newToolBar.AddToolbarButton("", "NewButton", "Open a file.", openMacro)
' Display the toolbar
newToolBar.Visible = True
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_AddToolbarButton()
;; This example creates a new toolbar called TestToolbar and inserts a
;; toolbar button into it. The toolbar is then displayed.
;; To remove the toolbar after execution of this macro, use the Customize Menu
;; option from the Tools menu.
(setq acadObj (vlax-get-acad-object))
(setq currMenuGroup (vla-Item (vla-get-MenuGroups acadObj) 0))
;; Create the new toolbar
(setq newToolBar (vla-Add (vla-get-Toolbars currMenuGroup) "TestToolbar"))
;; Assign the macro string the VB equivalent of "ESC ESC _open "
(setq openMacro (strcat (Chr 3) (Chr 3) (Chr 95) "open" (Chr 32)))
(setq newButton (vla-AddToolbarButton newToolBar "" "NewButton" "Open a file." openMacro))
;; Display the toolbar
(vla-put-Visible newToolBar :vlax-true)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-31 02:48
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.