Microsoft KB Archive/106161

From BetaArchive Wiki
Knowledge Base


How to Convert Screen Object Positions Between Platforms

Article ID: 106161

Article Last Modified on 12/3/2003



APPLIES TO

  • Microsoft Visual FoxPro 3.0 Standard Edition
  • Microsoft FoxPro 2.5b
  • Microsoft FoxPro 2.5a
  • Microsoft FoxPro 2.5b
  • Microsoft FoxPro 2.5b for Macintosh



This article was previously published under Q106161


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 query words: VFoxWin FoxMac FoxWin 2.50 floating transport

Keywords: KB106161