ColorFormat, ImageHeight, ImageWidth Properties

Purpose

These properties define the ImageList creation parameters.

Syntax

ImageList.ColorFormat [ = flags ]

ImageList.ImageHeight [ = h ]

ImageList.ImageWidth [ = w ]

flags, h, w:iexp

Description

The properties describe the type of image list to create. After adding the first image to the control, these properties are read-only. The ImageList control is not created before the first item is added.

ColorFormat = flags specifies a value how to create the image list. This can be one of the following flags:

0 Device dependent bitmap with a mask.
4 Use 4-bpp (bits-per-pixel) DIB Section.
8 Use 8-bpp DIB Section.
16 Use 16-bpp DIB Section.
24 Use 24-bpp DIB Section.
32 Use 32-bpp DIB Section.

By adding 1 to the flags value the respective image list is created without a mask; therefore, flags = 1, 5, 9, 17, 25, 33 do NOT create a mask (this is opposite to the way VB and the API operate so may cause some confusion - see here for a fuller explanation).

When the first image added contains a palette, the ImageList control creates a list with a palette.

The ImageHeight and ImageWidth properties define the height and width of the images in pixels.

Example

OpenW 1, 30, 30, 300, 300

Cls colBtnFace

Ocx ImageList iml

iml.ImageWidth = 32

iml.ImageHeight = 32

iml.ColorFormat = 1

iml.MaskColor = $0c0c0c

iml.UseMaskColor = True

//iml.ListImages.Add , "new", LoadPicture(":new") - Requires an inline picture titled ":new"

iml.ListImages.Add , "app", CreatePicture(LoadIcon(Null, IDI_APPLICATION))

Dim p As Picture : Set p = iml.ListImage(1).ExtractIcon

PaintPicture p, 0, 0

Do : Sleep : Until Win_1 Is Nothing

Remarks

When the ImageList control is bound to another Ocx control, all images in the ListImages collection - no matter what their size - will be displayed in the second (bound control) at the size specified by the ImageHeight and ImageWidth properties.

See Also

ImageList, ListImages

{Created by Sjouke Hamstra; Last updated: 29/05/2021 by James Gaite; Other Contributors: Jean-Marie Melanson}