TextHeight, TextWidth Method

Purpose

Determines a string's height and width in ScaleMode units.

Syntax

x! = [Object.]TextHeight(a$)

x! = [Object.]TextWidth(a$)

Object:Ocx Object
x!: Single
a$: sexp

Description

Returns the height and width of a character expression with respect to the average character width for the font of Ocx object Object. Without a specified Object the current active output object is used (Form or Printer).

Example

Local a$ = "Hello World", tx%(2, 2)

OpenW 1, , , 400, 200

AutoRedraw = 1

FontName = "Arial" : FontSize = 20

tx(1, 1) = TextHeight(a$), tx(1, 2) = TextWidth(a$)

ScaleMode = basTwips

tx(2, 1) = TextHeight(a$), tx(2, 2) = TextWidth(a$)

FontSize = 9

Print "Height in Pixels: "; tx(1, 1)

Print "Width in Pixels: "; tx(1, 2)

Print "Height in Twips: "; tx(2, 1)

Print "Width in Twips: "; tx(2, 2)

FontSize = 20

ScaleMode = basPixels

Line 0, 100, 300, 100

Text 50, 100 - TextHeight(a$) / 2, a$

Remarks

See Also

Form, ScaleMode

{Created by Sjouke Hamstra; Last updated: 25/10/2014 by James Gaite}