You can use the Draw method of the ListImage
object to draw an image on another object. As discussed
earlier, an image from the ImageList control can be
loaded into a PictureBox by setting the Picture
property:
Picture1.Picture = ImageList1.ListImages(1).Picture
You can also use the Draw method to accomplish
the same thing. With Draw, however, you have some additional options. The syntax
for Draw is as follows:
ImageList1.ListImages(Index).Draw (HDC, x,y, style)
where Index identifies the image to be drawn. The Key value can be used in
place of the Index as well. HDC is the device context ID of the destination device.
If you were to draw an image onto a form, for example, you could specify Form1.HDC
for the HDC property. This tells Windows where to put an image. The optional parameters,
x and y, identify the coordinates within the destination at which the image will
be drawn. The Style property can take one of the following four values:
- imlNormal (0) The image will appear normally—with
style = 1.
- mlTransparent (1) The part of the image will appear to be
transparent. Transparency is determined by the MaskColor property (set on the
Color tab of the Custom Properties dialog box).
- imlSelected (2) The image will be dithered with the system
highlight color.
- imlFocus (3) The image appears as if it has focus.
Related topics on ImageList Control