|
-
Apr 16th, 2007, 04:21 AM
#1
Thread Starter
Frenzied Member
Selecting Font Size
VB6, GDI . . .
If I have a textbox, and I want to resize the font so that the textbox width can only contain a certain number of characters regardless of size how do I calculate the font size?
Thanks in advance
"As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein
It's turtles! And it's all the way down
-
Apr 16th, 2007, 05:58 PM
#2
Junior Member
Re: Selecting Font Size
I'm not sure what the property is called, but it lets you set the max number of characters allowed in a textbox, for now I'll call it MaxChars. You would want to play with these values since I don't have vb on this computer, I'm not sure if it works, but it would look somewhat like this:
vb Code:
text1.MaxChars = (text1.font.size / 2) - text1.font.size
Now I don't know if this will work, but the goal is that the larger the font the less characters allowed. (Actually that doesn't work at all, and I don't have time to figure out what will, but you should have a general idea of how you would go about doing it)
-
Apr 17th, 2007, 01:59 AM
#3
Thread Starter
Frenzied Member
Re: Selecting Font Size
[vbcode]
txtEdit.MaxLength = uField.Geometry.LineQty * uField.Geometry.LineLength
lWidth = txtEdit.Width
lFontSize = 72 * 1.5 * (lWidth / GetDeviceCaps(picDocument.hdc, LOGPIXELSY))
lFontSize = lFontSize / uField.Geometry.LineLength
txtEdit.FontSize = lFontSize
[/vbcode]
Seems to work quite nice indeed!
Cheers.
"As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein
It's turtles! And it's all the way down
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|