PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Selecting Font Size-VBForums
Results 1 to 3 of 3

Thread: Selecting Font Size

  1. #1

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    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

  2. #2
    Junior Member
    Join Date
    Mar 2007
    Location
    New Jersey
    Posts
    30

    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:
    1. 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)
    Final Fantasy Tactics Online
    Blank Engine (3D, Opensource, VB Engine)(Under construction but does have a download)

  3. #3

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    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
  •  



Featured


Click Here to Expand Forum to Full Width