How to Get a String’s Width in Pixels, Not in Characters

To determine the width of a string in pixels using the active font and output it’s best to use this method:

  (* sString - (string) Can be any string constant or variable.
  **
  ** For example:
  **   TCanvas.TextWidth('m3Rlin');
  **   TCanvas.TextWidth(Edit1.Text);
  **   TCanvas.TextWidth(OpenDialog1.FileName);
  *)
  TCanvas.TextWidth(sString);

Tags: , , , , , , , , , , , ,

No Comments Yet

You can be the first to comment!

Leave a comment

OpenID Login

Standard Login