drawTextWidth

drawTextWidth(text: String): Real;

The drawTextWidth method of the Window class returns the width of the graphical text output that would result from drawing the passed text string with the drawTextAt method. The text parameter is the text string.

The returned value is a Real primitive type in the units of the scaleMode property of the form or control. The width of the text is calculated based on a single line of text, unless it has embedded carriage return characters within it forcing new lines.

The method in the following example shows the use of the drawTextWidth method.

centerText(graphWin: Window; text: String;
           pos: Integer; vertical: Boolean): Integer;
begin
    if vertical then
        return(pos + (graphWin.drawTextHeight(text).Integer/2)).Integer;
    else
        return(pos - (graphWin.drawTextWidth(text).Integer/2)).Integer;
    endif;
end;