Move label within boundary of picture box
Move label within boundary of picture box
API Declarations
paste the code and enjoy with it.
Rate Move label within boundary of picture box
(1(1 Vote))
Private Sub label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
xm = x
ym = y
End Sub
Private Sub label1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
'Label1.Caption = Label1.Tag & " x- " & x & " Y- " & y
label1.Left = label1.Left + x - xm
label1.Top = label1.Top + y - ym
BOUND label1, picture1
End If
End Sub
Private Sub BOUND(L As Label, P As PictureBox)
If L.Left + P.Left < P.Left Or L.Left < 0 Then L.Left = 0
If L.Top + P.Top < P.Top Or L.Top < 0 Then L.Top = 0
If L.Width + L.Left > P.ScaleWidth Then L.Left = P.ScaleWidth - L.Width
If L.Top + L.Height > P.ScaleHeight Then L.Top = P.ScaleHeight - L.Height
End Sub
Move label within boundary of picture box Comments
No comments yet — be the first to post one!
Post a Comment