The AImageList object defines a list of images, used for example, on an AToolBar.
An AImageList control contains a collection of AImageListImage objects, each of which can be referred to by its index or key. The AImageList control is not meant to be used alone, but as a central repository to conveniently supply other controls with images.
The AImageList control functions as a storehouse for images, and as such, it needs a second control to display the stored images. The second control can be any control that can display an image's Picture object, or it can be one of the Windows Common Controls that were specifically designed to bind to the AImageList control. These include the AToolBar control. In order to use an AImageList with one of these controls, you must bind a particular AImageList control with the second control through an appropriate property. For the Toolbar control, you must set the ImageList property to an AImageList control.
At design time, you can add images using the Images tab of the AImageList Control Properties dialog box. At run time, you can add images using the InsertImage method.
Important: When using the AImageList control with an AToolBar control, insert all of the images you will require, in the order you desire, into the AImageList before binding it to the second control. Once the AImageList is bound to a second control, you cannot delete images, and you cannot insert images into the middle of the Images collection. However, you can add images to the end of the collection.
Once you associate an AImageList with an AToolBar control, you can use the value of either the Index or Name property to refer to a AImageListImage object in a procedure. The following example sets the Image property of a AToolBar control's third AToolBarButton object to the first AImageListImage object in an AImageList control:
! Use the value of the Index property of iml1.
tbr1.Buttons(3).Image = 1
! Or use the value of the Name property.
tbr1.Buttons(3).Image = iml1.Images("image 1")
To use the AImageList control with other controls (that cannot be bound to the AImageList control), assign the Picture property of the second control to the Picture object of any image in the AImageList control. For example, the following code assigns the Picture object of the first AImageListImage object in a AImageList control to the Picture property of a newly created AStatusBarPane object:
sbrp = sbr1.Panes.InsertPane() ! Add a new Pane object.
sbr1.Picture = iml1.Images(1).Picture ! Set Picture.
You can insert any size image into the AImageList control. However, the size of the image displayed by the second control depends on one factor: whether or not the second control is bounded to the AImageList control.
When the AImageList control is bound to another control, images of different sizes can be added to the control, however the size of the image displayed in the associated control will be constrained to the size of the first image added to the AImageList. For example, if you add an image that is 16 by 16 pixels to an AImageList control, then bind the AImageList to an AToolBar control (to be displayed with AToolBarButton objects), all images stored in the AImageList control will be displayed at 16 by 16 pixels, even if they are much larger or smaller.
On the other hand, if you display images using the Picture object, any image stored in the AImageList control will be displayed at its original size, no matter how small or large.