![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
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!
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 PropertiesAny 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 objects 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 containers ScaleMode property. If you change a containers 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 objects interiorthat is, the area available for graphics operations. These specifications are different from those provided by Height and Width properties, which indicate the objects 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 objects 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 controls container object. You can also set this property, which would have the effect of moving a control from one container to another. Although Ive never seen this technique used in a program, I suppose it might be of value somewhere.
Now lets look at a program that demonstrates some techniques you can use to improve your programs screen display. We want the program to do two things:
At startup, this programs form always displays in the center of the screen with a size equal to half the screen size. For this, we use the forms 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 forms size and position. Heres what well do:
|
![]() |
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. |