Results 1 to 5 of 5

Thread: [RESOLVED] Positioning text in picturebox

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Resolved [RESOLVED] Positioning text in picturebox

    Hello, does anybody know how to position text (X and Y) so that the complete text always stays in the picturebox and on the right bottom side, no matter what size the picturebox has and no matter what font name and size is used?

    Thank you.







    VB Code:
    1. Private Sub Command1_Click()
    2.     Pic.FontName = "Arial"
    3.     Pic.ForeColor = vbWhite
    4.     Pic.FontBold = True
    5.     Pic.FontSize = 12
    6.     Pic.CurrentX = '??????
    7.     Pic.CurrentY = '??????
    8.     Pic.Print "Testing"
    9. End Sub
    Last edited by Chris001; Oct 26th, 2006 at 01:02 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Positioning text in picturebox

    Try this quicky:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim strText$
    3.  
    4.     strText = "Hello World"
    5.    
    6.     With Picture1
    7.         .AutoRedraw = True
    8.         .Font.Size = 20
    9.         .Font.Name = "Arial"
    10.         .CurrentX = .ScaleWidth - .TextWidth(strText)
    11.         .CurrentY = .ScaleHeight - .TextHeight(strText)
    12.         Picture1.Print strText
    13.     End With
    14.  
    15. End Sub

  3. #3
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Positioning text in picturebox

    You'd need to cut the text length in half first, otherwise it's still going to be skewed...

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Positioning text in picturebox

    That works great. Thank you

  5. #5

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