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==]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top