Visual Basic: Windows Controls

DisabledImageList, HotImageList, ImageList Properties Example

The following example demonstrates the use of the DisableImageList, HotImageList, and ImageList properties. Notice that all three image lists use the same Key property. The example assumes that three ImageList controls named imgNormal, imgHot, and imgDisabled have been placed on a form.

Private Sub Form_Load()
   Dim str As String
   str = "D:\VB\Icons\Misc\" ' Change to match your graphics location.
   imgNormal.ListImages.Add Key:="face", _
   Picture:=LoadPicture(str & "Face02.ico")
   imgHot.ListImages.Add Key:="face", _
   Picture:=LoadPicture(str & "Face03.ico")
   imgDisabled.ListImages.Add Key:="face", _
   Picture:=LoadPicture(str & "Face01.ico")

   ' Set the ImageList, DisableImageList, and HotImageList properties.
   With Toolbar1
      .ImageList = imgNormal
      .DisabledImageList = imgDisabled
      .HotImageList = imgHot
      .Buttons.Add Caption:="Sad", Image:="face", Style:=tbrCheck
      .Buttons.Add Caption:="Happy", Image:="face", Style:=tbrCheck
      .Buttons.Add Caption:="Face", Image:="face", Style:=tbrCheck
      .Buttons(1).Enabled = False
      .Buttons(3).Value = tbrPressed
   End With
End Sub