is it possible for me to make my own slider bar control using a label?
Printable View
is it possible for me to make my own slider bar control using a label?
Yes. GIGO
whats "GIGO"?
Garbage in Garbage out. You didn't specify a problem!
i'm trying it so that the user can click on the label, and darg it up or down (not sideways) but to a limited area, like a slide control
To use this properly create two Labels. Label2 is the Length of the slider. Put it in front of the first label (The one thats going to scroll). Make it transparent and change the colour of the first label to something like black.Code:Option Explicit
Dim Moving As Boolean
Dim OldY As Integer
Private Sub Label2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X >= Label1.Left - Label2.Left And X <= Label1.Width And _
Y >= Label1.Top - Label2.Top And Y <= Label1.Height + Label1.Top Then
Moving = True
OldY = Y
Else: Moving = False
End If
End Sub
Private Sub Label2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Moving = True And Y > 0 And Y < Label2.Height Then
If Label1.Top + Y - OldY >= Label2.Top And _
Label1.Top + Y - OldY + Label1.Height <= Label2.Top + Label2.Height Then
Label1.Move Label1.Left, Label1.Top + Y - OldY
Else
If Label1.Top + Y - OldY <= Label2.Top Then
Label1.Move Label1.Left, Label2.Top
Else
Label1.Move Label1.Left, Label2.Top + Label2.Height - Label1.Height
End If
End If
OldY = Y
End If
End Sub
Private Sub Label2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Moving = False
End Sub
thanks a lot