How to get the text width in pixels when a component doesn't have a canvas (Views: 100)
How to get the text width in pixels when a component doesn't have a canvas
If a component doesn't have a Canvas property you can use the following function to get the text width based on the font passed.
function GetTextWidth(CanvasOwner: TForm; Text: string; TextFont: TFont): Integer;
OldFont := TFont.Create;
Result := CanvasOwner.Canvas.TextWidth(Text);
<< Back to main page