ColorResList example for Visual Basic

Note: Also works with Access 95 and 97.

This example changes the hue of bitmaps in a list, then plays the list as an animation. When changing the hue, it preserves the transparent color.

Dim i As Integer  ' Loop counter
Dim uCount As Integer ' Number of bitmaps in the list
Dim TransparentColor As Long ' Color used for transparency

' Save the current transparent color.
TransparentColor = Lead1.BitmapTransparentColor

' Avoid repaints while we modify the bitmaps.
Lead1.AutoRepaint = False

' Change the hue of each bitmap in the list,
' and restore the transparent color as the last color in the palette.
uCount = Lead1.BitmapListCount
For i = 0 To uCount - 1
   Lead1.BitmapListIndex = i
   Lead1.Hue i * 10
   Lead1.BitmapPalette(255) = TransparentColor
Next i

' Get an optimized palette for the whole list.
Lead1.ColorResList 8, CRP_OPTIMIZEDPALETTE, CRD_NODITHERING, 0

' Update the palette that is used for playback.
For i = 0 To 255
   Lead1.AnimationPalette(i) = Lead1.BitmapPalette(i)
Next i

' Start the animation.
Lead1.AutoRepaint = True
Lead1.AnimationEnable = True