Visual Basic 6 Black Book:Picture Boxes And Image Controls
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Visual Basic can help out here because picture boxes give you some rudimentary graphics-drawing capabilities that you can make use of in code. In particular, you can draw lines and circles, and set points to particular colors in picture boxes using the following methods (note, by the way, that you can also use all the following methods with forms as well as picture boxes).
Some of the following methods make use of CurrentX and CurrentY; these are properties that you can set in a picture box. For example, if you omit the first set of coordinates when using the Line() method, Visual Basic draws the line from the location (CurrentX, CurrentY).
You may want to specify measurements to the graphics methods using pixels, not the default twips, and you can change the measurements in a picture box to pixels by setting its ScaleMode property this way:
Private Sub Form_Load()
Picture1.ScaleMode = vbPixels
End Sub
Well start working with the drawing methods of picture boxes now, starting with the Circle() method.
Drawing Circles
You use the Circle() method to draw circles:
PictureBox.Circle [Step] ( x, y), radius, [color, start, end, aspect]
Here are the arguments you pass to Circle():
StepKeyword specifying that the center of the circle, ellipse, or arc is relative to the current coordinates given by the CurrentX and CurrentY properties of object.
x, ySingle values indicating the coordinates for the center point of the circle, ellipse, or arc. The ScaleMode property of object determines the units of measure used.
radiusSingle value indicating the radius of the circle, ellipse, or arc. The ScaleMode property of object determines the unit of measure used.
colorLong integer value indicating the RGB color of the circles outline. If omitted, the value of the ForeColor property is used. You can use the RGB function or QBColor function to specify the color.
start, endSingle-precision values. When an arc or a partial circle or ellipse is drawn, start and end specify (in radians) the beginning and end positions of the arc. The range for both is 2 pi radians to 2 pi radians. The default value for start is 0 radians; the default for end is 2 * pi radians.
aspectSingle-precision value indicating the aspect ratio of the circle. The default value is 1.0, which yields a perfect (nonelliptical) circle on any screen.
As an example, we draw a circle in a picture box with this code:
Private Sub Command1_Click()
Picture1.Circle (80, 70), 50
End Sub
The result of this code appears in Figure 10.9. If there were an image already in the picture box, the circle would appear drawn on top of it.
Figure 10.9 Drawing a circle in a picture box.
Drawing Lines
You use the Line() method to draw lines:
PictureBox.Line [Step] ( x1, y 1) [Step] ( x2, y2), [ color], [B][F]
Here are the arguments you pass to Line():
StepKeyword specifying that the starting point coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
x1, y1Single values indicating the coordinates of the starting point for the line or rectangle. The ScaleMode property determines the unit of measure used. If omitted, the line begins at the position indicated by CurrentX and CurrentY.
StepKeyword specifying that the end-point coordinates are relative to the line starting point.
x2, y2Single values indicating the coordinates of the end point for the line being drawn.
colorLong integer value indicating the RGB color used to draw the line. If omitted, the ForeColor property setting is used. You can use the RGB function or QBColor function to specify the color.
BIf included, causes a box to be drawn using the coordinates to specify opposite corners of the box.
FIf the B option is used, the F option specifies that the box is filled with the same color used to draw the box. You cannot use F without B. If B is used without F, the box is filled with the current FillColor and FillStyle. The default value for FillStyle is transparent.
Setting Points
You use PSet() to set points in a picture box:
PictureBox.PSet [Step] ( x, y), [ color]
Here are the arguments you pass to PSet():
StepKeyword specifying that the coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
x, ySingle values indicating the horizontal (x-axis) and vertical (y-axis) coordinates of the point to set.
colorLong integer value indicating the RGB color specified for point. If omitted, the current ForeColor property setting is used. You can use the RGB function or QBColor function to specify the color.
TIP: In a picture box, you set the color of figures with the ForeColor property and the fill color with the FillColor property.
TIP: If you want your images to persist (in other words, be redrawn automatically when needed), set the picture boxs AutoRedraw property to True.
Using Image Lists With Picture Boxes
When handling images, its often useful to use image lists. An image list is an invisible control whose only purpose is to hold images. A common thing to do is to load images into an image list and then when theyre all loaded (and stored in memory, not on the disk), place them rapidly into picture boxes as needed.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
323 326326 32721 (323)bizuteria;slubna,kategoria,323AMP E 323więcej podobnych podstron