1 / 12

VB Graphics Controls & Timer Control

VB Graphics Controls & Timer Control. Default Controls. Graphics File Formats used with VB. Using Images. At design time: Select a image thru the Picture property (form, Picture box or Image Box) At Runtime: Form1.Picture = LoadPicture(“C:MYPIC.BMP”)

lgerry
Download Presentation

VB Graphics Controls & Timer Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VB Graphics Controls& Timer Control

  2. Default Controls

  3. Graphics File Formats used with VB

  4. Using Images • At design time: Select a image thru the Picture property (form, Picture box or Image Box) • At Runtime: Form1.Picture = LoadPicture(“C:\MYPIC.BMP”) Image1.Picture = LoadPicture(“D:\PAMELA.JPG”) Picture1.Picture = image1.Picture Picture1.Picture = LoadPicture(“”) • Passing an empty string to the LoadPicture function clears the current picture.

  5. Using Images with Forms • At design time: Select a form background image thru the Picture property • At Runtime: Form1.Picture = LoadPicture(“C:\MYPIC.BMP”) • picture that is placed directly on a form. If you want the picture to be a different size, you need to resize the original graphic file using a graphics utility.

  6. Using Images with Forms • Placing the picture directly on the form have several drawbacks: • You cannot hide the picture; it can only be loaded or unloaded. • You cannot control the placement of the picture on the form. • You can place only one picture at a time on the form. • You cannot resize the picture. It’s placed on the form in its original (saved) size. • You can overcome these drawbacks by using the Picture or Image control.

  7. Image Control • Provides a frame for the picture, allowing you to position it anywhere on the form. • Pictures can be resized. • Stretch property: • False (the default): the Image control is automatically resized to fit the picture you assign to it. • True: the picture is automatically resized so that the entire picture fits within the current boundaries of the Image control.

  8. PictureBox Control • Although the PictureBox control uses more system resources than the Image control, it has some added features: • Can be used as a container for other controls • Drawing methods (for example, Line and Print) can be used to draw on the picture box • PictureBox does not allow resizing of the picture • Setting AutoSize property to True cause the PictureBox control to resize itself to fit the current picture.

  9. The Timer Control • Executes code (in its Timer event) when the interval is complete. • Counts down repeatedly, as long as the Enabled property is set to True. • Designed to work with very small amounts of time; the maximum setting is just a little longer than a minute. • Uses: scheduling and performing repeated operations.

  10. Setting Up the Timer • First draw it on the form, it does not show up at all while your program is running. • Place code in the Timer event and then set the following properties, either at designtime or runtime: • Set the Interval property. • Set the Enabled property to True. The Interval property can be set to any value between zero and 65,535.

  11. The Timer Control • The Enabled property acts like a switch that turns your timer on and off. If the Timer control is enabled, the code in the Timer event is executed at the end of the time specified in the Interval property. • The Interval property can be set to any value between zero (disables the Timer control) and 65,535 milliseconds. • 10 seconds = 10,000 milliseconds.

  12. Creating a Simple Animation Following is an example of using the timer control for a simple animation. Set the Interval property to 200 and the Enabled property to True.

More Related