SET PAUSE

TextHeight, TextWidth

The TextHeight and TextWidth methods return the size of a supplied text string, in pixels.

Usage

nHeight = objFormOrScreen.TextWidth( cString ) nWidth = objFormOrScreen.TextHeight( cString )
These methods are handier versions of the TxtWidth() and FontMetric() functions. They return the size a text string will take up on a Form or on the _SCREEN, expressed in pixels. The calculation is based on the current output window's text name, size and style.

TextWidth returns the length of the longest line of text, if carriage returns are included in the supplied string. TextHeight increases correctly as well, but only if the string includes linefeed characters. This is not the case with VFP 3.x, where TextWidth returns the width for the whole string, as if the carriage returns were printable characters. For VFP 3.x, use MemLines() and MLine() to parse the string into individual lines and pass them to TextWidth(). With VFP 5.0 and later, this bug has been squashed.

Example

_SCREEN.FontName = "Arial" _SCREEN.FontSize = 10 nHowWide = _SCREEN.TextWidth("How wide is my string?")   && 134 nHowHigh = _SCREEN.TextHeight("How high is my string?")  && 16

See Also

FontMetric, MemLines(), MLine(), TxtWidth(), ScaleMode


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net