How to Convert Screen Object Positions Between Platforms

Last reviewed: April 29, 1996
Article ID: Q106161
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b
  • Microsoft FoxPro for the Macintosh, version 2.5b

SUMMARY

When you transport FoxPro applications between character-based and graphic- based environments, you must convert the row and column positions of screen objects appropriately, as explained below.

MORE INFORMATION

In FoxPro for MS-DOS, objects are placed based on row and column positions. The size of each row and column remains constant, since only one screen font is available. However, in FoxPro for Windows and FoxPro for the Macintosh, row and column sizes will vary based on the current font and the current resolution of the screen.

In order to provide a consistent unit of measurement and accurate placement of objects between platforms, foxels were developed. Foxels are simply fractional rows and columns, expressed in decimal form. A foxelrow is used to indicate a single vertical row of characters. A foxelcol is used to indicate a single horizontal character.

The size of a foxelrow will vary depending on the height of the current font. The number of foxelrows available can be determined with the SROWS() function. The size of a foxelcol will vary depending on the average width of characters in the current font. The number of foxelcols available can be determined with the SCOLS() function.

The algorithm to determine pixel-to-foxel conversion is:

   FUNCTION _pix2fox
      PARAMETER m.apixel,m.dimension
      RETURN m.apixel/FONTMETRIC(IIF(UPPER(m.dimension) = "H",6,1))

The following two parameters are passed to the function:
  • M.APIXEL indicates the pixel position.
  • M.DIMENSION indicates a "V" for vertical values and an "H" for horizontal values.

Usage

   myfoxelrow = _pix2fox(pixvalnum,"V") && for vertical (row) values
   myfoxelcol = _pix2fox(pixvalnum,"H") && for horizontal (col) values

The algorithm for foxelrows divides the pixel position by the character height in pixels for the current font. The algorithm for foxelcols divides the pixel position by the average character width in pixels for the current font.


Additional reference words: VFoxWin 3.00 FoxMac FoxWin 2.50 2.50a 2.50b
floating
transport
KBCategory: kbinterop
KBSubcategory: FxinteropGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.