Microsoft KB Archive/120291

{| = How Position & Size of @...SAY/GET Fields Are Calculated =
 * width="100%"|

ID: Q120291

2.5x 2.60 2.60a | 2.5x 2.60a

WINDOWS        | MACINTOSH kbother The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a
 * Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c, 2.6a

SUMMARY
Based on the position and size of GET (input) and SAY (output) objects in the Screen Builder, FoxPro calculates the vertical and horizontal coordinates and the size of the field. Then it writes these coordinates and sizes to the .SCX file. These numbers are then used by GENSCRN.PRG (invoked by choosing Generate from the Program menu) to create the corresponding .SPR file. This article describes the algorithm used by FoxPro to calculate these numbers on simple GET fields, not controls such as popups or push buttons.

MORE INFORMATION
You can see the numbers on which FoxPro bases its calculations. While in the Screen Builder, choose Show Position from the Screen menu. Then choose Ruler/Grid from the Screen menu, and select the Pixels radio button from the Ruler group.

Use the Field tool to draw an input (GET) or output (SAY) field, and note the pixel values of Top, Left, Height, and Width displayed in the status bar when the field is selected.

Assuming a GET field was created, the corresponding .SPR file is generated with the following command:

@, GET ; SIZE fHeight, fWidth ; ... FONT , The coordinates and are taken from the VPOS and HPOS fields from the corresponding record in the underlying .SCX file. The fHeight and fWidth values are the HEIGHT and WIDTH fields in that file. The numbers written to the .SCX and .SPR files are calculated by using the following formulas:

VPOS = ( + 1)/FONTMETRIC(1,, )

HPOS = ( + 2)/FONTMETRIC(6,, )

HEIGHT = ( - 2)/FONTMETRIC(1,, )

WIDTH = ( - 5)/FONTMETRIC(6,, ) , , , and  are the pixel values displayed in the status bar when the field is selected in the Screen Builder.  is the font in which the window was defined. You can see this either by choosing Layout from the Screen menu and then choosing the Font push button, or by looking at the DEFINE WINDOW command in the .SPR file.

 is the font in which the field was defined. By default, this is the same font as . However, you can change it by selecting the object and choosing Font from the Object menu or by looking at the FONT clause for that object in the .SPR file.

NOTE: The above formulas assume you are using a "normal" (or "regular" or "plain") font style. If this is not the case, you must add a fourth argument to the FONTMETRIC function to specify the font style.