Results 1 to 9 of 9
  1. #1
    sufokeet
    Guest

    Physical string lenght

    I am looking for a way to calculate the physycal length of a string. Not the number of characters! Font characteristics should therefore be parameters.

  2. #2
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Physical string lenght

    That's a very interesting problem. Why do you need this measurement?

  3. #3
    sufokeet
    Guest

    Re: Physical string lenght

    Yes I know it's an interesting question! But do you have a answer? Otherwise why are you asking?

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Physical string lenght

    Because sometimes the question that you ask isn't really what you need. If you explain what you're trying to do, someone may have already found a way and can share it. For example, if you were trying to use the physical length of a string to try and align columns of text in a list box, there are already several solutions to that problem posted in various web sites.
    Charlotte

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Physical string lenght

    I know how to do this. It is a Microsoft API function and a couple of lines of code.

  6. #6
    sufokeet
    Guest

    Re: Physical string lenght

    Thanks, but that doesn't ring a bell with me. Could you be more specific?

  7. #7
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Physical string lenght

    Thank you Charlotte. This is the second time you've come to my defence re: responses to this persons posts. I'll not bother him again with my apparently ignorant responses.

  8. #8
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Physical string lenght

    You will require GetTextExtentPoint to calculate the width and height of the text string. The result is in pixels so you will then require GetDeviceCaps to convert the pixels to a inch (or cm) size.

    If you were more polite to others then they may return information to you in a useful format. The above information will get you started. Have fun.

  9. #9
    sufokeet
    Guest

    Re: Physical string lenght

    Thank you very much for your help. I have fun and wish you have also a lot.

    John

Posting Permissions

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