ExtractIcon Method Example

This example loads a bitmap into an ImageList control. When the user clicks the form, the ExtractIcon method is used to create an icon from the bitmap, and that icon is used as a setting in the Form object's MouseIcon property. 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 imgX As ListImage
   Set imgX = ImageList1.ListImages. _
   Add(, , LoadPicture("bitmaps\assorted\balloon.bmp"))
End Sub

Private Sub Form_Click()
   Dim picX As Picture
   Set picX = ImageList1.ListImages(1).ExtractIcon  ' Make an icon.
   
   With Form1
   .MouseIcon =  picX   ' Set new icon.
   .MousePointer = vbCustom    ' Set to custom icon.
   End With
End Sub