getTextHeightForWidth

getTextHeightForWidth(str:   String;
                      width: Integer): Integer;

The getTextHeightForWidth method of the Window class returns the height in pixels required to display the string specified in the str parameter as it would be displayed when word wrapped within a rectangle of the width specified in the width parameter using the font of the window. The string is treated as a single line, unless it contains carriage return characters, in which case this method returns the total height of all of the lines.

This method is similar to the Window class getTextHeight method except that the getTextHeight method returns the height without word wrap (a single line unless the text contains carriage return characters).

The code fragment in the following example returns the height of the textBox1 text using word wrapping for a width of 80 using the font of the label1 control.

hgt := label1.getTextHeightForWidth(textBox1.text, 80);