Download presentation
Presentation is loading. Please wait.
Published byLuke Warner Modified over 8 years ago
1
Slide 1 VB Graphics Controls & Timer Control
2
Slide 2 Default Controls
3
Slide 3 Graphics File Formats used with VB
4
Slide 4 Using Images v At design time: Select a image thru the Picture property (form, Picture box or Image Box) v At Runtime: Form1.Picture = LoadPicture(“C:\MYPIC.BMP”) Image1.Picture = LoadPicture(“D:\PAMELA.JPG”) Picture1.Picture = image1.Picture Picture1.Picture = LoadPicture(“”) v Passing an empty string to the LoadPicture function clears the current picture.
5
Slide 5 Using Images with Forms v At design time: Select a form background image thru the Picture property v At Runtime: Form1.Picture = LoadPicture(“C:\MYPIC.BMP”) v 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
Slide 6 Using Images with Forms v 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. v You can overcome these drawbacks by using the Picture or Image control.
7
Slide 7 Image Control v Provides a frame for the picture, allowing you to position it anywhere on the form. v Pictures can be resized. v 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
Slide 8 PictureBox Control v 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 v PictureBox does not allow resizing of the picture v Setting AutoSize property to True cause the PictureBox control to resize itself to fit the current picture.
9
Slide 9 The Timer Control v Executes code (in its Timer event) when the interval is complete. v Counts down repeatedly, as long as the Enabled property is set to True. v Designed to work with very small amounts of time; the maximum setting is just a little longer than a minute. v Uses: scheduling and performing repeated operations.
10
Slide 10 Setting Up the Timer v First draw it on the form, it does not show up at all while your program is running. v 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
Slide 11 The Timer Control v 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. v The Interval property can be set to any value between zero (disables the Timer control) and 65,535 milliseconds. v 10 seconds = 10,000 milliseconds.
12
Slide 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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.