Visual Basic 6 Black Book:Working With Graphics
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
Setting Drawing Scales
Forms and picture boxes have a number of scale properties, and perhaps the most popular one is ScaleMode, which sets the units of measurement in a picture box. Here are the possible values for ScaleMode (note that when you set the scale mode of a picture box, all measurements are in those new units, including coordinates passed to your program, like mouse down locations):
vbUser0; indicates that one or more of the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties are set to custom values
vbTwips1 (the default); twip (1440 twips per logical inch; 567 twips per logical centimeter)
vbPoints2; point (72 points per logical inch)
vbPixels3; pixel (smallest unit of monitor or printer resolution)
vbCharacters4; character (horizontal equals 120 twips per unit; vertical equals 240 twips per unit)
vbInches5; inch
vbMillimeters6; millimeter
vbCentimeters7; centimeter
vbHimetric8; HiMetric
vbContainerPosition9; units used by the controls container to determine the controls position
vbContainerSize10; units used by the controls container to determine the controls size
For example, to report the mouse location in pixels in a form using two text boxes, Text1 and Text2, we set the forms ScaleMode property to vbPixels when the form loads:
Private Sub Form_Load()
ScaleMode = vbPixels
End Sub
This means that the X and Y values for the mouse location passed to us will be in pixels, so we can display those coordinates in the text boxes this way:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As _
Single, Y As Single)
Text1.Text = "Mouse x location (in pixels): " & Str(X)
Text2.Text = "Mouse y location (in pixels): " & Str(Y)
End Sub
The result of the preceding code appears in Figure 18.14.
Figure 18.14 Displaying mouse location in pixels.
If you set the scale mode to vbUser, you can define your own units by setting the dimensions of the picture box using the ScaleLeft, ScaleTop, ScaleWidth, and ScaleHeight properties. This can be very useful if youre plotting points and want to use a picture box as a graph.
TIP: The ScaleWidth and ScaleHeight properties of a picture box hold the images actual dimensions (in units determined by the ScaleMode property), not the Width and Height properties, which hold the controls width and height (including the border).
The code for this example is located in the pixelmouse folder on this books accompanying CD-ROM.
Using The Screen Object
The Visual Basic Screen object offers you a lot of information about the current display. Here are that objects properties:
TwipsPerPixelXTwips per pixel horizontally
TwipsPerPixelYTwips per pixel vertically
HeightScreen height
WidthScreen width
FontsCollection of names of the available fonts
FontCountTotal number of screen fonts available
ActiveControlCurrently active control
ActiveFormCurrently active form
MouseIconReturns or sets a custom mouse icon
MousePointerReturns or sets a value indicating the type of mouse pointer displayed when the mouse is over a particular part of an object at runtime
Resizing Graphics When The Window Is Resized
The Testing Department is on the phone. When the user resizes your SuperDuperGraphicsPro program, the graphics in the program dont resize themselves. You ask, should they? They say, yes.
You can use the Resize event to catch window or picture box resizes. Lets see an example. Here, we add a new subroutine, DrawBox, to a form. This subroutine draws a rectangle in a form:
Private Sub DrawBox()
Line (ScaleWidth / 4, ScaleHeight / 4)(3 * ScaleWidth / 4, _
3 * ScaleHeight / 4), , B
End Sub
We can call DrawBox in the Load event to draw the box the first time (set the forms AutoRedraw property to True to draw graphics in the Form Load event):
Private Sub Form_Load()
DrawBox
End Sub
When the user resizes the form, we clear the form and redraw the box in the Form Resize event:
Private Sub Form_Resize()
Cls
DrawBox
End Sub
Now the program resizes its graphics to match the users actions. The code for this example is located in the resizer folder on this books accompanying CD-ROM.
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:
609 611README (609)604 606Nuestro Circulo 609 VUGAR VASHIMOV604 606609 613W Ziemi Obiecanej (1615 606 p n e )609 612606 (2)PIONEER PDR 609606 613609 (2)ONKYO KODY DO PILOTA 506,576,606,5100codeswięcej podobnych podstron