ref:: tutorial 13 a question

Started by
3 comments, last by Spider_In_A_Web 22 years, 6 months ago
I was wondering if it is possible to calculate the length of the string drawn to screen in tutorial 13?? This is done in tutorial 14, but i would like to be able to do it with the text produced in number 13!! Thanks for your help on this and other questions i have asked!! Chrs
Advertisement
With "strlen" ?

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Ist the length of the string on screen i require not the amount of characters in it!!

in tutorial 14, this is done using a loop that gets the distance from each character to the next, but I cannot work out how to do this with the text from method 13!!

is it possible, or does anyone have any suggestions!
Only way would be to guess the pixel width of each character of a font and see which width works best.

Or load up the font from the windows directory take a snapshot of it and count the length in pixels manually in Paint
Alright, to get the length of a string in a window using a windows font, you can use the win32 function GetTextExtentExPoint(), which can also return the positions at which you need to break the string in order to get it to fit within the boundaries that you want. Look it up on MSDN, and it tells you exactly how to use it. If you''re going to be using multiple fonts, then you''ll have to keep the HFONT for each font that you create so that you can select it again before you make this call, as it will use whatever font is currently selected.

jw

This topic is closed to new replies.

Advertisement