Text pixel width and height

  • Thread starter Thread starter Peter Oliphant
  • Start date Start date
P

Peter Oliphant

Given a Font and a String*, how can I find out the PIXEL width and height of
the resulting text displayed on the screen? Obviously this is necessary to
center text, especially those using proportional fonts...

Thanks in advance for responses! : )

[==P==]
 
Given a Font and a String*, how can I find out the PIXEL width and height of
the resulting text displayed on the screen? Obviously this is necessary to
center text, especially those using proportional fonts...

Try GetTextExtent (or one of it's variants).

Depending on quite what you're doing DrawText with DT_CENTER may be
easier though.

Dave
 
Hi Dave,

I think I found what I'm looking for. It's a function in the Graphics class
called MeasureString(string*, font* )... : )

[==P==]
 
Back
Top