PRB: Instance of Container Class Uses Parent Form ScalemodeID: Q130132 3.00 WINDOWS
The information in this article applies to:
SYMPTOMSObjects added to an instance of a Container Class by a program are placed according to the Scalemode property of the parent form. Although a Container Class has no Scalemode property, an instance inherits the parent's Scalemode property from the form on which it is placed. This occurs regardless of the Scale Units selected in the Class page of the Class Info dialog.
RESOLUTIONHere are two techniques you can use to ensure that objects added to the container are properly sized and placed:
STATUSThis behavior is by design.
MORE INFORMATIONA Visual FoxPro form has a Scalemode property that governs how objects programatically placed will be located and sized. There are two Scalemodes, foxels (0) and pixels (3). A container class, when instantiated and placed on a form, has no Scalemode property. The location and size of any objects placed in this container is governed by the Scalemode value of the parent form. The following examples demonstrate two methods you can use to ensure that objects added to containers are properly placed and sized.
Method One - Change the Parent Scalemode to the Desired Setting1. Create a form called SCALTEST.SCX. 2. Set the Scalemode property to 3 - Pixels. 3. Save and close the form. 4. Create a new class by choosing New from the File menu. Select Class 5. Use Container_test as the class name, and select Container from the
6. Choose Class Info from the Class menu. Then set the Scale Units
7. Add a property called Scalemode by choosing New Property from the Class
8. Set the Height and Width properties of the class to 12 and 35.
9. Create the following program to run the form and programmatically add
Method One NotesOf the two methods, this is the better choice. The Scalemode property of the Container_test Class serves as a holder for the value. It is to be used to set the parent form scalemode, but has no effect in itself. Proper placement and sizing of the command button occurs regardless of the form scalemode. If the parent scalemode was not temporarily reset, the command button would appear very small because the scalemode would be pixels. Temporarily setting the form scalemode does not affect objects already placed on it, but does affect objects placed on it after the change is made.
Method Two - Determine Parent Scalemode and Place Objects Accordingly1. Create the Form and the Class library as above. 2. Create and run the following program:
NOTE: Method two requires more code and makes more calculations for both
scalemodes, so it is less elegant than Method One.
Additional reference words: 3.00 VFoxWin KBCategory: kbprb KBSubcategory: FxprgClassoop
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |