CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

GetBitmaps Method (ActiveX)

2023-1-4 09:55| 发布者: admin| 查看: 622| 评论: 0|来自: AutoCAD

摘要: 获取用作工具栏项图标的大小位图。

获取用作工具栏项图标的大小位图。

支持的平台:仅窗口

签名

工 务 局:

object.GetBitmaps SmallIconName, LargeIconName
对象

类型:工具栏项

此方法适用的对象。

小图标名称

访问:仅输出

类型:字符串

小位图的路径和文件名。

大图标名称

访问:仅输出

类型:字符串

大位图的路径和文件名。

返回值(RetVal)

无返回值。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_GetBitmaps()
    ' This example uses MenuGroups to obtain a reference to the AutoCAD main menu.
    ' It then creates a new Toolbar (TestMenu) and inserts a ToolBarButton
    ' with a custom icon into it. The menu is automatically shown.
    '
    ' * NOTE: The paths of the icons for the new toolbar should be updated
    ' before running this example.
        
    Dim currMenuGroup As acadMenuGroup
    Dim newToolBar As AcadToolbar, newToolBarButton As AcadToolbarItem
    Dim openMacro As String
    Dim SmallBitmapName  As String, LargeBitmapName  As String
    
    On Error GoTo ERRORTRAP
    
    ' Use MenuGroups property to obtain reference to main AutoCAD menu
    Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("ACAD")
    
    ' Create the new Toolbar in this group
    Set newToolBar = currMenuGroup.Toolbars.Add("TestMenu")
    
    ' Add an item to the new Toolbar and assign an Open macro
    ' (VBA equivalent of: "ESC ESC _open ")
    openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32)
    Set newToolBarButton = newToolBar.AddToolbarButton(newToolBar.count + 1, "Open", "Open Macro", openMacro, False)
   
    ' Read icon paths for this Toolbar button
    GoSub READPATHS
    
    ' Change the default icon (smile face) for the new toolbar button
    SmallBitmapName = "c:\AutoCAD\16x16.bmp"     ' Use a 16x16 pixel .BMP image
    LargeBitmapName = "c:\AutoCAD\32x32.bmp"     ' Use a 32x32 pixel .BMP image
    newToolBarButton.SetBitmaps SmallBitmapName, LargeBitmapName
    
    ' Read icon paths for this Toolbar button
    GoSub READPATHS
    
    Exit Sub
    
READPATHS:
    ' Read icon paths for this Toolbar button
    newToolBarButton.GetBitmaps SmallBitmapName, LargeBitmapName
    MsgBox "The new Toolbar uses the following icon files: " & _
           vbCrLf & vbCrLf & "Small Bitmap: " & SmallBitmapName & vbCrLf & _
           "Large Bitmap: " & LargeBitmapName

    Return

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

Visual LISP:

(vl-load-com)
(defun c:Example_GetBitmaps()
    ;; This example uses MenuGroups to obtain a reference to the AutoCAD main menu.
    ;; It then creates a new Toolbar (TestMenu) and inserts a ToolBarButton
    ;; with a custom icon into it. The menu is automatically shown.
    ;;
    ;; * NOTE: The paths of the icons for the new toolbar should be updated
    ;; before running this example.
    (setq acadObj (vlax-get-acad-object))
    (setq currMenuGroup (vla-Item (vla-get-MenuGroups acadObj) 0))
     
    ;; Create the new Toolbar in this group
    (setq newToolBar (vla-Add (vla-get-Toolbars currMenuGroup) "TestToolbar"))
    
    ;; Add an item to the new Toolbar and assign an Open macro
    ;; (VBA 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))
   
    ;; Read icon paths for this Toolbar button
    (vla-GetBitmaps newButton 'SmallBitmapName 'LargeBitmapName)
    (alert (strcat "The new Toolbar uses the following icon files: \n"
                   "Small Bitmap: " SmallBitmapName "\n"
                   "Large Bitmap: " LargeBitmapName))
  
    ;; Change the default icon (smile face) for the new toolbar button
    (setq SmallBitmapName "C:\\AutoCAD\\16x16.bmp")     ;; Use a 16x16 pixel .BMP image
    (setq LargeBitmapName "C:\\AutoCAD\\32x32.bmp")     ;; Use a 32x32 pixel .BMP image
    (vla-SetBitmaps newButton SmallBitmapName LargeBitmapName)
    
    ;; Read icon paths for this Toolbar button
    (vla-GetBitmaps newButton 'SmallBitmapName 'LargeBitmapName)
    (alert (strcat "The new Toolbar uses the following icon files: \n"
                   "Small Bitmap: " SmallBitmapName "\n"
                   "Large Bitmap: " LargeBitmapName))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 20:23

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部