Results 1 to 5 of 5

Thread: Label Auto sizer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66

    Label Auto sizer

    I have a label say label1. When ever I enter some words which is more than what can be shown in that label it truncates the surplus words and displays the label. Like say if label1 can only 10 words then if I enter this "Information Technology" then label1 only shows "Informatio" nothing else. I want this to automatically adjust the font of the lable so that the entire "Information Technology" fits into it. In other words if the sentence is more it must reduce its font size and finally fit it in the label. The logic is : The font must go on reducing till the entire sentence is fitted into. The reverse must also work if less is entered then font size should increase. Please help with codings. Thanks.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    don't u think the font will get awfully small if type, um, say "waka waka length, blah blah, telephone, more stuff"?

    maybe resize the label?

    but, have a look at:
    Public Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hDC As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As Size) As Long

    or even

    [Form name].TextWidth

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66
    Font won't get awful as I am allowing the user to preview the font. If it is worse then he can remove some words by editing.

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Couldn't you just set the AutoSize property to True?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    66
    No I can't set the AutoSize property to True as I have space restrictions.

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