12 02 NE62WXCQ3Q2JLESYNI7G7DSFME2CT32FEG7PYOQ




Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!: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 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6! (Publisher: The Coriolis Group) Author(s): Peter G. Aitken ISBN: 1576102815 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





Table 12.2 MousePointer property settings.



Setting
Description

0
Shape determined by the object (default)

1
Arrow

2
Cross (cross-hair pointer)

3
I-Beam

4
Icon (small square within a square)

5
Size (four-pointed arrow pointing north, south, east, and west)

6
Size NE SW (double arrow pointing northeast and southwest)

7
Size N S (double arrow pointing north and south)

8
Size NW SE (double arrow pointing northwest and southeast)

9
Size W E (double arrow pointing west and east)

10
Up arrow

11
Hourglass (wait)

12
No drop

13
Arrow and hourglass

14
Arrow and question mark

15
Size all (can be customized under Microsoft Windows NT 3.51 and 4.0)

99
Custom icon specified by the MouseIcon property



picture specifies the name and path of the icon or cursor file that should be used as the mouse cursor when the MousePointer property is set to 99.
The ActiveForm property returns the form that is currently active. You will find this property useful in a multiple-form program when you want to write one section of code that will always reference the active form. For example, the line


Screen.ActiveForm.MousePointer = 4


will change the MousePointer property of whatever form happens to be active at the time the code is executed.
A few other Screen properties are available, but I will leave those until we need them.
Position And Size Properties
Any Visual Basic object displayed on the screen has properties that determine its position and size. The Top and Left properties specify the position of the object’s top-left corner within its container, and the Height and Width properties specify its size. All four of these properties use the coordinate units specified by the container’s ScaleMode property. If you change a container’s ScaleMode property, during either program design or execution, the properties of any objects in the container automatically change to the new units.
Two other properties, ScaleHeight and ScaleWidth, apply only to the Form, Picture Box, and Printer objects. These properties provide the dimensions of the object’s interior—that is, the area available for graphics operations. These specifications are different from those provided by Height and Width properties, which indicate the object’s overall size, including borders, title bar, and other object components. The most common use for the ScaleHeight and ScaleWidth properties is at runtime: The program reads them to determine the container object’s interior size and then uses the values to position objects or perform drawing operations within the container. You will see how to accomplish this in the first demonstration program, presented later in this chapter.
Take a moment to look at Figure 12.1, which shows the relationships between objects and their containers. Note the three levels of “containerness” in this diagram: A Command Button has been placed in a Frame; the Frame is on a Form; and the Form is on the Screen.
All Visual Basic controls have a Container property, which returns the identity of the control’s container object. You can also set this property, which would have the effect of moving a control from one container to another. Although I’ve never seen this technique used in a program, I suppose it might be of value somewhere.

Figure 12.1  Every Visual Basic object is contained within another object, with the Screen object being the top-level container.


TIP:  Using Controls As Containers
Two controls—the Picture Box and the Frame—can serve as containers for other controls. Why would you want to use this feature? For Option Buttons, it’s a necessity. Two or more Option Buttons placed in a Frame are treated as a group, and you can select only one of the options at a time. For other control types, however, it remains a matter of design convenience. Because controls that are drawn on a Frame or Picture Box move as their container is moved, you can move them together once you create a group of related controls on a Frame or Picture Box.

To place controls on a Frame or Picture Box, first draw the container control on the form and then draw the controls on the container. If you use another method—such as dragging an existing control onto a Frame—it will look like it is on the Frame, but it will neither move with the Frame, nor be positioned with respect to the Frame’s origin.


Now let’s look at a program that demonstrates some techniques you can use to improve your program’s screen display. We want the program to do two things:


•  Display the form at a specified size and position when the program starts
•  Maintain the relative sizes and positions of the form’s controls when the user resizes the form

At startup, this program’s form always displays in the center of the screen with a size equal to half the screen size. For this, we use the form’s Load event procedure. The Load event occurs just before a form is displayed, and this is when the program starts for a single-form program. The Load event procedure is the ideal place to perform various initialization steps, such as setting a form’s size and position. Here’s what we’ll do:

•  To set the form size to half the screen size, we will set the Form object’s Width and Height properties equal to half of the Screen object’s Width and Height properties.
•  To center the form left-to-right, we subtract the Form object’s Width from the Screen object’s Width, divide the result by 2, and place the result in the Form’s Left property.
•  To center the form top-to-bottom, we subtract the Form object’s Height from the Screen object’s Height, divide the result by 2, and place the result in the Form’s Top property.





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. Read EarthWeb's privacy statement.



Wyszukiwarka