-
Jul 27th, 2021, 02:17 AM
#1
Thread Starter
Member
[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
-
Jul 27th, 2021, 04:28 AM
#2
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
-
Jul 27th, 2021, 07:42 AM
#3
Thread Starter
Member
Re: Drawing a line / rectangle on a form
Originally Posted by westconn1
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|