Hi Nicholas,
I'm trying to get string input from the user to fit into a textbox. I
want to allow writing strings into this textBox, until a certain length
(the textbox width).
I'm validating the length that the function returns using the
measureString / measureCharacterRanges return values. This gives me the
length of the string the user has typed in.
For example:
A string "aaaaa" that is 20 pixels long, and a string "www" that is 10
pixels long. The problem arises when the "www" string, that is shorter
in pixels, looks longer on the screen than the "aaaa" string.
I check stringLength versus textBoxLength to see if stringLength has
exceeded textBoxLength. If it has, i do not want to print it on the
screen. So, although in pixels the string fits in the textBox and passes
the check, visually it does not and it overflows.
The function getTextExtentPoint32 gives the opposite trouble. It does
measure the string properly, not allowing an overflow, only now it
truncates some inputs in the middle.
Thanks, Shimrit
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!