ID: Q120291
2.5x 2.60 2.60a | 2.5x 2.60a
WINDOWS | MACINTOSH
kbother
The information in this article applies to:
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.
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:
@<vpos>,<hpos> GET <variable> ;
SIZE fHeight, fWidth ; ...
FONT <fontname>,<fontsize>
The coordinates <vpos> and <hpos> 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 = (<Top> + 1)/FONTMETRIC(1,<WindowFont>,<pointsize>)
HPOS = (<Left> + 2)/FONTMETRIC(6,<WindowFont>,<pointsize>)
HEIGHT = (<Height in pixels> - 2)/FONTMETRIC(1,<ObjectFont>,<pointsize>)
WIDTH = (<Width in pixels> - 5)/FONTMETRIC(6,<ObjectFont>,<pointsize>)
<Top>, <Left>, <Height>, and <Width> are the pixel values displayed in the
status bar when the field is selected in the Screen Builder.
<WindowFont> 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.
<ObjectFont> is the font in which the field was defined. By default, this is the same font as <WindowFont>. 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.
FoxPro "Developer's Guide," Appendix A FoxPro "Language Reference," FONTMETRIC function
For information about converting screen object positions between platforms, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q106161
TITLE : How to Convert Screen Object Positions Between
Platforms
Additional reference words: FoxMac FoxWin 2.50 2.50a 2.50b 2.50c 2.60 2.60a
foxels
KBCategory: kbother
KBSubcategory: FxtoolSbuilder
Keywords : FxtoolSbuilder
Version : 2.5x 2.60 2.60a | 2.5x 2.60a
Platform : MACINTOSH WINDOWS
Last Reviewed: May 1, 1996