RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCanvas.TextExtent Method

Returns the width and height, in pixels, of a string rendered in the current font.

Pascal
function TextExtent(const Text: string): TSize;
C++
__fastcall TSize TextExtent(const AnsiString Text);

Use TextExtent to determine the space a string will occupy in the image. Other elements in the image such as lines, boxes, or additional lines of text can be positioned to accommodate the size of the text. TextExtent returns the width and height of the rectangle that bounds the text on the canvas. 

To check only the height, call TextHeight. To check only the width, call TextWidth

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!