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 1:上面的代码 可以生成一个工具条,但是关掉生成的toolbar后 ,再运行程序就会出错, 可能是关掉的toolbar没有卸载完。怎么彻底删除toolbar? 2: 生成的toolbar,上面的按钮只能实现打开、保存等功能,怎么能点击按钮后调用自己 的函数来实现其他功能? 急切等待您的指点
|