Returns the width, in pixels, of a string rendered in the current font.
function TextWidth(const Text: string): Integer;
function TextWidth(const Text: WideString): Integer;
Description
Use TextWidth to determine the length a string will occupy in the image. TextWidth indicates whether a given string will fit in the available space. Other graphical elements in the image such as lines, or additional strings can be positioned to accommodate the width of the text.
TextWidth returns the same value as TextExtent(Text).cx.
var
i: Integer;
begin
with PageControl1 do
begin
for i := 0 to PageCount - 1 do
begin
if (Canvas.TextWidth(Pages[i].Caption) * 2) > TabWidth then
TabWidth := Canvas.TextWidth(Pages[i].Caption) * 2;
if (Canvas.TextHeight(Pages[i].Caption) * 2) > TabHeight then
TabHeight := Canvas.TextHeight(Pages[i].Caption) * 2;
end;