Skip to content

ImageList Control ​

Wraps the ImageList control, used to store and manage image collections for reference by other controls.

Enumerations ​

ImlImageSizeConstants ​

ConstantValueDescription
imlSmall0Small icons (16×16)
imlLarge1Large icons (32×32)
imlCustom2Custom size

CCBackStyleConstants ​

See Common Enumerations.

Properties ​

ImageWidth ​

vb
Property Get ImageWidth() As Long
Property Let ImageWidth(ByVal Value As Long)

Image width (pixels).

ImageHeight ​

vb
Property Get ImageHeight() As Long
Property Let ImageHeight(ByVal Value As Long)

Image height (pixels).

ImageSize ​

vb
Property Get ImageSize() As ImlImageSizeConstants
Property Let ImageSize(ByVal Value As ImlImageSizeConstants)

Preset image size. Setting this property automatically adjusts ImageWidth and ImageHeight.

ColorDepth ​

vb
Property Get ColorDepth() As Long
Property Let ColorDepth(ByVal Value As Long)

Color depth. Supports 4, 8, 16, 24, 32 bits. Requires comctl32.dll 6.0 or later.

MaskColor ​

vb
Property Get MaskColor() As OLE_COLOR
Property Let MaskColor(ByVal Value As OLE_COLOR)

Mask color.

UseMaskColor ​

vb
Property Get UseMaskColor() As Boolean
Property Let UseMaskColor(ByVal Value As Boolean)

Whether to use mask color.

BackColor ​

vb
Property Get BackColor() As OLE_COLOR
Property Let BackColor(ByVal Value As OLE_COLOR)

Background color.

hImageList ​

vb
Property Get hImageList() As LongPtr

Image list handle. Read-only.

ListImages ​

vb
Property Get ListImages() As ImlListImages

Image collection.

Name ​

vb
Property Get Name() As String

Control name. Read-only.

Tag ​

vb
Property Get Tag() As Variant
Property Let Tag(ByVal Value As Variant)
Property Set Tag(ByVal Value As Variant)

Custom data.

Parent ​

vb
Property Get Parent() As Object

Parent object. Read-only.

Container ​

vb
Property Get Container() As Object
Property Set Container(ByVal Value As Object)

Container object.

Left ​

vb
Property Get Left() As Single
Property Let Left(ByVal Value As Single)

Left margin.

Top ​

vb
Property Get Top() As Single
Property Let Top(ByVal Value As Single)

Top margin.

Width ​

vb
Property Get Width() As Single
Property Let Width(ByVal Value As Single)

Width (used at design time).

Height ​

vb
Property Get Height() As Single
Property Let Height(ByVal Value As Single)

Height (used at design time).

Visible ​

vb
Property Get Visible() As Boolean
Property Let Visible(ByVal Value As Boolean)

Visibility (used at design time).

hWnd ​

vb
Property Get hWnd() As LongPtr

Window handle. Read-only.

Methods ​

Refresh ​

vb
Sub Refresh()

Forces a repaint.

CreateIcon ​

vb
Function CreateIcon(ByVal ImageIndex As Long) As IPictureDisp

Creates an icon from the specified image.

CreateBitmap ​

vb
Function CreateBitmap(ByVal ImageIndex As Long) As IPictureDisp

Creates a bitmap from the specified image. Requires comctl32.dll 6.0 or later.

Overlay ​

vb
Function Overlay(ByVal ImageIndex1 As Long, ByVal ImageIndex2 As Long) As IPictureDisp

Overlays two images and returns the resulting image.

AboutBox ​

vb
Sub AboutBox()

Displays the About dialog.

Sub-objects ​

ListImage (ImlListImage) ​

Represents a single image in the image list.

Properties ​

PropertyTypeAccessDescription
IndexLongRead-onlyIndex in the collection
KeyStringRead/WriteKey in the collection
TagVariantRead/WriteCustom data
PictureIPictureDispRead/WriteImage
MaskPictureIPictureDispRead/WriteMask image
OverlayBooleanRead/WriteWhether this is an overlay image
OverlaySourceIndexLongRead/WriteOverlay source index
ExtractIconIPictureDispRead-onlyExtract icon
ExtractBitmapIPictureDispRead-onlyExtract bitmap

ListImages (ImlListImages) ​

Image collection object.

Properties ​

PropertyTypeAccessDescription
Item(ByVal Index As Variant)ImlListImageRead-onlyGet image by index or key
CountLongRead-onlyNumber of images

Methods ​

MethodDescription
Add([Index], [Key], [Picture], [MaskPicture]) As ImlListImageAdd an image
Exists(ByVal Index As Variant) As BooleanCheck if an image exists
ClearClear all images
Remove(ByVal Index As Variant)Remove the specified image

Code Examples ​

vb
' Set image size and add images
With ImageList1
    .ImageSize = imlSmall
    .ListImages.Add , "open", LoadPicture("open.ico")
    .ListImages.Add , "save", LoadPicture("save.ico")
    .ListImages.Add , "exit", LoadPicture("exit.ico")
End With

' Reference image by key
Set cmdOpen.Picture = ImageList1.ListImages("open").ExtractIcon

' Create overlay image
ImageList1.ListImages.Add , "overlay1", LoadPicture("ov1.ico")
ImageList1.ListImages("overlay1").Overlay = True
ImageList1.ListImages("overlay1").OverlaySourceIndex = 1

' Use Overlay method to overlay two images
Set imgOverlay = ImageList1.Overlay(1, 2)

' Iterate through all images
Dim img As ImlListImage
For Each img In ImageList1.ListImages
    Debug.Print img.Index; img.Key
Next img

twinBASIC and LOGO copyright of "WaynePhillipsEA" author