Results 1 to 6 of 6

Thread: Textwidth question

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Textwidth question

    How can I know the width of a string for a specific fontsize, fonttype etc?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Textwidth question

    Originally posted by krtxmrtz
    How can I know the width of a string for a specific fontsize, fonttype etc?
    using the printer object if you set the font and then use the printer.textwidth method... that should do it for ya

  3. #3
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Picture boxes also support .TextWidth.

    Probably even the Form.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by DiGiTaIErRoR
    Picture boxes also support .TextWidth.

    Probably even the Form.
    yeah form does as well.. i suggested the printer object because it is built in and you can change the font without it affecting your form or anything... but if you can use form i would recommend that... as i found out the hard way.. calls to the printer object will fail if windows doens't have a printer installed

  5. #5
    Addicted Member
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    143

    What you mean?

    I don't really get what you mean.
    But i know how to make a label/textbox roughy the same lenght as the text.
    First, fontname is fixedsys.
    then:

    info.width = Len(info2.Caption) * 125

    I learn this while creating WWP
    Unignal Software Team Developer
    -------------------------------------------
    Current Project:
    Noter Light
    -------------------------------------------
    http://www.unignal.sg.tf

  6. #6
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    set the font first for info and info2 then
    VB Code:
    1. info.width = TextWidth(Info2.Caption)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width