Using the Microsoft Windows Common Controls
In this exercise, you will implement various Microsoft Windows Common Controls in a Visual Basic application. The
Animation control will display an AVI of the user 's choice and a toolbar will be added to allow an alternative to a form's command button.
* To use the Animation control
- Start a new Standard EXE project in Visual Basic.
- Add the Microsoft Windows Common Controls 5.0 , Microsoft Windows Common Controls-2 5.0 , and Microsoft Common Dialog Control 5.0 components to the project.
- Add the Animation control , Common Dialog control and a command button to a blank form.
Be sure to make the Animation control large enough on the form to display an AVI file.
- Name the command button cmdPlay and set its caption to Play .
- In the click event for cmdPlay add the following code:
With CommonDialog1 .Filter = "avi (*.avi)*.avi" .ShowOpen End With With Animation1 .AutoPlay = True .Open CommonDialog1.filename End With
- Save the project to WA\Practice\Ch12 and run the application.
- When you click Play , locate the file filedel.avi in the c:\Program Files\DevStudio\Vb\Graphics\AVIs folder.
- Stop the application.
* To use the toolbar control - Add a Toolbar and an ImageList to frmMain.
The Toolbar should be aligned to the top of the form. You may have to reposition the controls that are currently on the form.
- Right-click the ImageList and choose Properties .
- Set the image size to 16 X 16 .
- Choose the Images tab.
- Click Insert Picture and locate the open.bmp file in the c:\Program Files\DevStudio\Vb\Graphics\Bitmaps\Outline folder.
- Click OK to close the property sheet for the ImageList .
- Right-click the Toolbar and choose Properties .
- In the ImageList box, select ImageList1 .
- Select the Buttons tab and click Insert Button .
- Set the Image property to 1.
- Click OK to close the property sheet for the Toolbar .
- Double-click the Toolbar and add the following code:
If Button.Index = 1 Then Play_Click End If
- Save and test your work.