Defining the Toolbar Button Image

To set and retrieve the bitmaps of the icons associated with a toolbar button, you can use the SetBitmaps and GetBitmaps methods. Both methods have similar syntax and require two parameters (see Table 16-14), one for each of the two icons (small and large).

ToolbarItemObject.SetBitmaps SmallIconName, LargeIconName ToolbarItemobject.GetBitmaps SmallIconName, LargeIconName

Table 16-14. The SetBitmaps and GetBitmaps Methods' Parameters


Data Type




The path and file name for the small bitmap

(16x15 pixels)



The path and file name for the small bitmap

(24x22 pixels)

The following code example sets the small and large icons for the Line button of the toolbar you just created with the previous code. Note that here I'm using bitmaps I created and stored in the C:\Apress\ folder, so, if you want to try this code, you'll need to uncomment the SetIcons line in the previous code and change the path and file information to suitable files on your machine.

Public Sub SetIcons(strIconSmall As String, strIconLarge As String) Dim objToolBarItem As AcadToolbarItem

Set objToolBarItem = ThisDrawing.Application.MenuGroups(0).Toolbars( _

"Custom Toolbar Create")("Line")

objToolBarItem.SetBitmaps strIconSmall, _


End Sub

■ Note Autodesk has sought Microsoft Windows XP logo certification for the entire AutoCAD product line. One of the requirements of this logo certification involves toolbar icon graphics. If you intend to develop software for marketing, you should seriously investigate these requirements if you want to produce products that coincide with the base platform (AutoCAD) on which they're used. Refer to the MSDN Web site at http:// for more information.

Was this article helpful?

0 0

Post a comment