Visual Basic Concepts
You can create simple animation by changing pictures at run time. The easiest way to do this is to toggle between two images. You can also use a series of pictures to create animation with several frames. Also, by moving the picture dynamically, you can create more elaborate effects.
Some icons can be used in pairs. For instance, there are two matching envelope icons in the \Vb\Graphics\Icons subdirectory, one with the envelope unopened and one with the envelope torn open, as shown in Figure 12.12. By switching, or toggling, between the two, you can create an animation that shows your user the status of mail.
Figure 12.12 Mail icons
The following statement changes the Picture property of an image control named imgMailStatus to toggle its picture from an unopened envelope to an open envelope.
imgMailStatus.Picture = imgMailOpen.Picture
You can also rotate through several pictures to make longer animations. This technique is basically the same as toggling between two pictures, but requires the application to select which bitmap acts as the current image. One way to control the individual pictures in an animation is with a control array.
For More Information See "Creating Arrays of Objects" in "Programming with Objects" for more information about control arrays.
The Blanker sample application includes an animation that shows a rotating moon. The Spinning Moon demo uses an array of nine image controls to create the animation. To view how the images in a control array work with each other at run time, choose Spinning Moon from the Options menu, and then choose the Start Demo button, which calls the ImageDemo procedure.