VISUAL BASIC_6
 

7. Animation Projects


In this lesson we will consider some three projects involving animation.   Animation is caused by the motion of inanimate objects.

1. Project using Animation Control:

The Animation control allows you to create buttons which display animations appropriate to the function perfomed by the computer.   For example, when a filecopy operation is perfomed, it will be appropriate when such a function is visually denoted by flying something  from the source to the destination.   In Windows 95, this function is denoted by pieces of paper flying from one folder to another folder.   Drag an animation control, a Common Dialog Control and two command buttons from the Toolbox.  The animation control will work only with silent avi files. Change the Caption property of command buttons as ‘play’ and ‘stop’ respectively and arrange them in the design window as shown in the figure 1.

                             Figure 1

Entering the code:

Open the code window by doubleclicking the command button and enter the codes as shown in the figure 1a.

 

Private Sub Command1_Click()

CommonDialog1.ShowOpen

Animation1.Open CommonDialog1.filename

Animation1.AutoPlay = True

End Sub

 

Private Sub Command2_Click()

Animation1.Close

Animation1.Stop

End Sub

 

     Figure 1a

 

Running the Project:

Select the Start button from the Run Menu.  The run mode window appears on the screen.   On clicking the play button, a file open dialog box appears.   You will find a number of avi files in the directory given by \program files\devstudio\vb\graphics\avi\ .   On selecting the file the animation display appears on the screen as shown in the figure 2.


                        Figure 2


 

Copyright © 2001 Selfonline-Education. All rights reserved.