Results 1 to 3 of 3

Thread: [RESOLVED] Drawing a line / rectangle on a form

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    32

    Resolved [RESOLVED] Drawing a line / rectangle on a form

    I have a form on which is a frame in in that is an image. On this image I have drawn a number of labels (a cross and some text). I would also like to draw some horizontal & vertical lines. I think I draw these using rectangles with width/height of 1.

    The code to draw the labels is:
    Code:
    Private Sub SetLabel(MyFrame As Frame, Mytop As Single, MyLeft As Single, MyCaption As String)
       Dim lblBox_n As Object
       
       Set lblBox_n = MyFrame.Controls.Add("Forms.Label.1", "lblBox_n", True)
       With lblBox_n
            .top = Mytop
            .left = MyLeft
            .caption = MyCaption
            .height = 8
            .width = 28
            .TextAlign = 1 ' left
            .ForeColor = vbRed
            .AutoSize = True
        End With
    End Sub
    Can you suggest similar code to draw a rectangle?

    Thank you

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,432

    Re: Drawing a line / rectangle on a form

    according to the way i read the code, all the labels are actually in the frame, not the image control, although they may appear above the image control

    I think I draw these u sing rectangles
    you can do this with a textbox height or width of 2 change bordercolor and borderstyle to suit, some other controls may also work as well, possibly frames, which are lightweight controls
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    32

    Re: Drawing a line / rectangle on a form

    Quote Originally Posted by westconn1 View Post
    you can do this with a textbox height or width of 2 change bordercolor and borderstyle to suit, some other controls may also work as well, possibly frames, which are lightweight controls
    Thank you. I ended up drawing it with a label, setting the height border colour & style as you suggested.
    Thanks

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