|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Drawing BoxesYou draw boxes in forms and picture boxes with the Line method, using the B argument: object.Line [Step] ( x1, y1) [Step] ( x2, y2), [color], [B][F] Here are the arguments you pass to Line:
Lets see an example showing how to draw boxes in forms and picture boxes when the user clicks a command button. In this case, well draw a box in a form
Private Sub Command1_Click()
Line (ScaleWidth / 4, ScaleHeight / 4)(3 * ScaleWidth / 4, 3 * _
ScaleHeight / 4), , B
and another box in a picture box:
Private Sub Command1_Click()
Line (ScaleWidth / 4, ScaleHeight / 4)(3 * ScaleWidth / 4, 3 * _
ScaleHeight / 4), , B
Picture1.Line (Picture1.ScaleWidth / 4, Picture1.ScaleHeight / 4)_
(3 * Picture1.ScaleWidth / 4, 3 * Picture1.ScaleHeight / 4), , B
End Sub
The result of this code appears in Figure 18.5. Now were drawing boxes in Visual Basic.
Drawing CirclesYou use the Circle method to draw circles in forms and picture boxes: object.Circle [Step] (x, y), radius, [color, [start, end, [aspect]]] Here are the arguments you pass to Circle:
As an example, we draw the biggest circle possible in both a form and a picture box, Picture1, when the user clicks a command button, Command1, using this code, and using a Switch function to determine if the forms width or height is larger:
Private Sub Command1_Click()
Circle (ScaleWidth / 2, ScaleHeight / 2), _
Switch(ScaleWidth >= ScaleHeight, ScaleHeight / 2, _
ScaleWidth < ScaleHeight, ScaleWidth / 2)
Picture1.Circle (Picture1.ScaleWidth / 2, Picture1.ScaleHeight / 2), _
Switch(Picture1.ScaleWidth >= Picture1.ScaleHeight, _
Picture1.ScaleHeight / 2, Picture1.ScaleWidth < _
Picture1.ScaleHeight, Picture1.ScaleWidth / 2)
End Sub
Running this code gives us the result you see in Figure 18.6.
The code for this example is located in the drawcircle folder on this books accompanying CD-ROM.
|
|
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. |