CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于定义工具栏按钮图像 (VBA/ActiveX)

2023-1-4 22:10| 发布者: admin| 查看: 593| 评论: 0|来自: AutoCAD

摘要: 若要定义要在工具栏按钮上使用的图像,请使用 SetBitmap 和 GetBitmaps 方法。

若要定义要在工具栏按钮上使用的图像,请使用 和 方法。SetBitmapsGetBitmaps

该方法采用两个参数:SmallIconName 和 LargeIconNameSetBitmaps

小图标名称
小图标名称标识小图像资源(16×16 位图)的 ID 字符串。字符串必须包含字母数字字符,除短划线 (-) 或下划线 (_) 外没有标点符号,并且应包括.bmp扩展名。资源可以是系统位图或用户定义的位图。用户定义的位图必须具有适当的大小,并且必须位于支持路径中。
大图标名称
大图标名称标识大图像资源的 ID 字符串(32×32 位图)。字符串必须包含字母数字字符,除短划线 (-) 或下划线 (_) 外没有标点符号,并且应包括.bmp扩展名。资源可以是系统位图或用户定义的位图。用户定义的位图必须具有适当的大小,并且必须位于支持路径中。

查询现有工具栏以查找按钮图标的名称

Sub Ch6_GetButtonImages()
 Dim Button As AcadToolbarItem
 Dim Toolbar0 As AcadToolbar
 Dim MenuGroup0 As AcadMenuGroup
 Dim SmallButtonName As String
 Dim LargeButtonName As String
 Dim msg As String
 Dim ButtonType As String

 ' Get the first toolbar in the first menu group
 Set MenuGroup0 = ThisDrawing.Application. _
 MenuGroups.Item(0)
 Set Toolbar0 = MenuGroup0.Toolbars.Item(0)

 ' Clear the string variables
 SmallButtonName = ""
 LargeButtonName = ""

 ' Create a header for the message box and
 ' display the toolbar to be queried
 msg = "Toolbar: " + Toolbar0.Name + vbCrLf
 Toolbar0.Visible = True

 ' Iterate through the toolbar and collect data
 ' for each button in the toolbar. If the toolbar is
 ' a normal button or a flyout, collect the small
 ' and large button names for the button.
 For Each Button In Toolbar0
 ButtonType = Choose(Button.Type + 1, "Button", _
 "Separator", "Control", "Flyout")
 msg = msg & ButtonType & ":   "
 If Button.Type = acToolbarButton Or _
 Button.Type = acToolbarFlyout Then
 Button.GetBitmaps SmallButtonName, _
 LargeButtonName
 msg = msg + SmallButtonName + ", " _
 + LargeButtonName
 End If
 msg = msg + vbCrLf
 Next Button

 ' Display the results
 MsgBox msg
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 18:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部