This example loads an image into an ImageList control. When you click the form, the image is drawn on the form in four different styles. To try the example, place an ImageList control on a form and paste the code into the form's Declarations section. Run the example and click the form.
Private Sub Form_Load()
Dim X As ListImage
'Load one image into the ImageList.
Set X = ImageList1.ListImages. _
Add(, , LoadPicture("bitmaps\assorted\intl_no.bmp"))
End Sub
Private Sub Form_Click()
Dim space, intW As Integer ' Create spacing variables.
' Use the ImageWidth property for spacing.
intW = ImageList1.ImageWidth
space = Form1.Font.Size * 2 ' Use the Font.Size for height spacing.
ScaleMode = vbPoints ' Set ScaleMode to points.
Cls ' Clear the form.
' Draw the image with Normal style.
ImageList1.ListImages(1).Draw Form1.hDC, , space,imlNormal
' Set MaskColor to red, which will become transparent.
ImageList1.MaskColor = vbRed
' Draw the image with red (MaskColor) the transparent color.
ImageList1.ListImages(1).Draw Form1.hDC, intW, space,imlTransparent
' Draw image with the Selected style.
ImageList1.ListImages(1).Draw Form1.hDC, intW * 2,space,imlSelected
' Draw image with Focus style.
ImageList1.ListImages(1).Draw Form1.hDC, intW * 3, space,imlFocus
' Print a caption for the images.
Print _
"Normal Transparent Selected Focus"
End Sub