ListImages Collection, ListImage Object

Purpose

A ListImages collection is a collection of ListImage objects. A ListImage object is a bitmap of any size (Picture object).

Syntax

imagelist.ListImages

imagelist.ListImages.ListImage(index)

imagelist.ListImages(index)

imagelist.ListImage(index)

index:Variant

Description

The ListImages and ListImage are a property of the ImageList Ocx control. The ListImages collection holds all the images, wrapped in a ListImage object, for the ImageList control.

The ListImages collection is a 1-based collection. index is an integer or string that uniquely identifies the object in the collection. The integer is the value of the Index property; the string is the value of the Key property.

You can add and remove a ListImage at design time using the 'ImageList Data' dialog box of the ImageList Properties, or at run time using the Add method for ListImage objects.

ListImages Properties and Methods

Add | Clear | Count | Item | Remove

ListImage Properties and Methods

Draw, | ExtractIcon | Index | Key | Picture | Tag

Note The ImageList control is an Ocx object for a ListImages collection of ListImage objects, where ListImage object is a holder of a Picture object. Therefore, the ImageList Ocx control holds a collection of Picture objects.

Example

OpenW Full 1

Dim pic As Picture

Local Int32 n, p1

// Find picture file

Local d$ = GetSetting("\\HKEY_CLASSES_ROOT\Applications\GfaWin32.exe\shell\open\command", , "")

If Left(d$, 1) = #34 Then d$ = Mid(d$, 2)

n = RInStr(d$, "\") : If n <> 0 Then d$ = Left(d$, n - 1)

If Not Exist(d$ & "\gfawintb.bmp") Then _

MsgBox("Can not locate gfawintb.bmp file"#13#10#13#10"Please manually place it in the GFABASIC32\Bin folder and try again.": End

Set pic = LoadPicture(d$ & "\gfawintb.bmp")

// Create ImageList and split picture up into separate icons

Ocx ImageList iml : .ImageHeight = 16 : .ImageWidth = 16

For n = 0 To 21 : iml.AddPart , , pic, (n * 16), 1 : Next n

// Add icons to TreeView object

Ocx TreeView tv = "", 10, 10, 100, 400 : .ImageList = iml

For n = 1 To 22 : tv.Add  , , , "Icon" & n, n : Next n

// Draw the icons as pictures using PaintPicture (reproduces exact size of 16x16)

For n = 0 To 21 : Set pic = iml(n + 1).ExtractIcon  : PaintPicture pic, 130, (n * 18: Next n

// Draw the icons as pictures using DrawIcon (reproduces enlarged size of 32x32)

For n = 0 To 21 : Set pic = iml(n + 1).ExtractIcon : ~DrawIcon(Me.hDC, 160, (n * 34), pic.Handle) : Next n

Do : Sleep : Until Me Is Nothing

Remarks

Images can also be inserted by using the ImageList Control methods Add and AddItem. This is a bit shorter, both in code and in executable instructions.

Dim img As ListImage

iml.Add , "open", LoadPicture(":open")

iml.AddItem , "save", LoadPicture(":save")

Set img = iml.Add( , "print1", LoadPicture(":print1"))

In the same way, items can be obtained in a shorter way. Use the ImageList control's ListImages or ListImage property.

Set img = iml.ListImages("open")

Set img = iml.ListImage("open")

See Also

ImageList

{Created by Sjouke Hamstra; Last updated: 12/10/2014 by James Gaite}