Presentation is loading. Please wait.

Presentation is loading. Please wait.

Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.

Similar presentations


Presentation on theme: "Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San."— Presentation transcript:

1 Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San Diego

2 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Ch 14: Graphics  Understand measurements in graphics coordinate system  Use RGB and QBColor functions to change colors  Create graphics  Load/change pictures at run time  Create simple animation  Use the timer control

3 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill The Graphics Environment  Measurement system is known as scale  Set scale to twips, point, pixels, inches or centimeters (default scale is twips)  Twip = 1/20 of a point; point = 1/72 inch  Pixel is Picture element  Graphic coordinates start at 0,0 (x,y) in upper-left corner of a form  Containers, such as picture boxes, have their own internal 0,0 point too

4 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Coordinate System  Coordinate system is the starting point for measuring the location of items within a control  Change the starting point, the scale, or both with the ScaleLeft, ScaleTop, ScaleWidth, and ScaleHeight properties  Image control, unlike the picturebox control, has a Stretch property—use Image control unless you need the added capabilities of a picturebox control

5 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Colors  Graphics controls have color properties: ForeColor, BackColor, FillColor  Graphics methods use RGB color functions and intrinsic color constants (e.g., vbRed)  The QBColor function converts older color numbers (0-15) to their RGB equivalent: frmMain.BackColor = QBColor(1) ‘Blue

6 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill The Graphics Methods  Graphics methods draw in a Form, Picturebox, or the Printer objects  Default object is the form  Cls, Pset, Line, and Circle are examples of graphics methods  Using methods to draw graphics is different from using graphics controls  Graphics controls persist. Graphics must be redrawn when form reappears

7 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill More Graphics Methods  DrawWidth property sets the size of dot  Line method connects two points with a line—it requires two sets of coordinates  Line method also draws rectangles by adding the B parameter  The Circle Method draws rounded shapes—circles, ovals, arcs and pie-shaped wedges

8 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Layering  Objects are placed on different layers when displayed  Back layer items are covered by middle layer items; front layer covers middle layer  Objects are placed in default layers  AutoRedraw and ClipControls properties affect the behavior of layers

9 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill More Properties of Graphics Controls  Add pictures at design time or run time  Place pictures in an image, picturebox, or form control—these have the Picture property  Picture property of form displays behind the controls on a form  The LoadPicture function loads a picture into a control at run time

10 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Simple Amimation  Animate an object by: –toggling between two pictures, moving a picture, –moving a picture, –or rotating through a series of pictures  VB icon library graphics often have two graphics of same size but opposite states (pushed in and out, for example)

11 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill The Timer Control  The Timer control triggers events at a programmer-specified time interval  Timer control is invisible at run time— simply place it on a form  Control triggers each time an interval elapses  Set the Interval property (0 to 65,535) in milleseconds; disable by setting timer’s Enabled property to False

12 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill More Graphics Techniques  Use the Scale method to change the scale of your coordinate system –[Object].Scale (x1, y1) - (x2, y2) –picLogo.Scale (0, 0) - (100, 100) changes the scale to 0 through 100  PaintPicture method places a graphic file on a form, picturebox, or the printer PaintPicture picLogo.Picture, 100, 100

13 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill The Scroll Bar Controls  Scroll bar controls –horizontal scroll bar –vertical scroll bar  Scroll bars often control sound level, color, size, and other values that change in small increments  Scroll bar properties: Min, Max, SmallChange, LargeChange, Value

14 Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill The Scroll Bar Controls horizontal scroll bar vertical scroll bar


Download ppt "Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San."

Similar presentations


Ads by Google