VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Move label within boundary of picture box

by Sohan Goel (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 8th September 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Move label within boundary of picture box

API Declarations


paste the code and enjoy with it.

Rate Move label within boundary of picture box




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


Download this snippet    Add to My Saved Code

Move label within boundary of picture box Comments

No comments have been posted about Move label within boundary of picture box. Why not be the first to post a comment about Move label within boundary of picture box.

Post your comment

Subject:
Message:
0/1000 characters