PDA

Click to See Complete Forum and Search --> : Line Control Problem


steve_rm
Apr 19th, 2002, 01:41 PM
Hello

I have many line controls on my form. I want to display a value in the middle of the line control. So when the user moves the line control at run - time, the value will always stay in the centre of the line.

Many thanks in advance

SLH
Apr 19th, 2002, 01:46 PM
Do you mean you want to display something at the centre of a line, or move the line's centre to where the user clicks??

steve_rm
Apr 19th, 2002, 01:51 PM
What to display something at the lines centre

steve_rm
Apr 19th, 2002, 01:52 PM
Dim YPos As Single
Dim XPos As Single

With Line1
XPos = .X2 - X1
YPos = .Y2 - Y1
End With

With Label1
.Left = XPos
.Top = YPos
End With

steve_rm
Apr 19th, 2002, 01:53 PM
I have tried that code, but it display the label at one end of the line and not the centre.

SLH
Apr 19th, 2002, 01:53 PM
Label1.left = Line.X1 + ((Line1.X2 - Line1.X1)/2) - (Label1.Width/2)
Label1.top = Line.Y1 + ((Line1.Y2 - Line1.Y1)/2)


Call that whenever the line moves.

EDIT: Changed for your objects, and made it place the label properly in the middle.

steve_rm
Apr 19th, 2002, 01:57 PM
Thanks for your reply. that piece of code works wonders.

Thanks

SLH
Apr 19th, 2002, 01:59 PM
Glad i could help :)