Pen Controls

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

  1. Start a new Standard EXE project in Visual Basic.
  2. 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.
  3. 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.

  4. Name the command button cmdPlay and set its caption to Play .
  5. 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 
  6. Save the project to WA\Practice\Ch12 and run the application.
  7. When you click Play , locate the file filedel.avi in the c:\Program Files\DevStudio\Vb\Graphics\AVIs folder.
  8. Stop the application.
* To use the toolbar control
  1. 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.

  2. Right-click the ImageList and choose Properties .
  3. Set the image size to 16 X 16 .
  4. Choose the Images tab.
  5. Click Insert Picture and locate the open.bmp file in the c:\Program Files\DevStudio\Vb\Graphics\Bitmaps\Outline folder.
  6. Click OK to close the property sheet for the ImageList .
  7. Right-click the Toolbar and choose Properties .
  8. In the ImageList box, select ImageList1 .
  9. Select the Buttons tab and click Insert Button .
  10. Set the Image property to 1.
  11. Click OK to close the property sheet for the Toolbar .
  12. Double-click the Toolbar and add the following code:
     If Button.Index = 1 Then    Play_Click End If 
  13. Save and test your work.


Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net