BCB: how to get the (approximate) width of a chartacter in a given TFont?

Posted by mawg on Stack Overflow See other posts from Stack Overflow or by mawg
Published on 2010-03-08T03:23:15Z Indexed on 2010/03/08 3:30 UTC
Read the original article Hit count: 146

Filed under:

It's a TMemo, not that that should make any difference.

Googling suggests that I can use Canvas->TextWidth() but those are Delphi examples and BCB doesn't seem to offer this property.

I really want something analgous to memo->Font->Height for width.

I realize that not all fonts are fixed width, so a good estimate will do.

All that I need is to take the width of a TMemo in pixels and make a reasonable guess at how many characters of the curretn font it will hold.

© Stack Overflow or respective owner

Related posts about c++builder