Wak
Nov 27th, 2000, 09:39 PM
I'm not to sure what this message should classify uder, but I think here is the right place.
I am making an Active X slider control, Bul I can't seem the get the slider to position properly on the background, for the slider. I am using two picture controls name picBack and picSlide. Below is my current code. Does anyone have a solution, or can find a problem which I can't see? I have used a timer, so find when the slider is off the edges of the bar. If anyone has either a whole new answer from another example of can find a bug. Mainly in Property Let Value(i as Integer) then it would be really great. Thanx
Option Explicit
Dim xFind As Integer
Private iMax As Integer
Dim blnCheck As Integer
Private iValue As Integer
Private Sub imgSlide_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then xFind = X
End Sub
Private Sub imgSlide_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnCheck = True Then Exit Sub
If Button = 1 Then imgSlide.Move imgSlide.Left + (X - xFind)
End Sub
Private Sub tmrSlider_Timer()
If imgSlide.Left < 0 Then
imgSlide.Left = 0
blnCheck = True
Else
blnCheck = False
End If
If (imgSlide.Left + imgSlide.Width) > imgBack.Width Then
imgSlide.Left = (imgBack.Width - imgSlide.Width)
blnCheck = True
Else
blnCheck = False
End If
End Sub
Property Get Value() As Integer
If iMax < iValue Then iMax = iValue
Value = iValue
End Property
Property Let Value(i As Integer)
If iMax < i Then iMax = i
Dim iPosition As Integer
Dim iAnswer As Integer
iPosition = ((imgSlide.Left + (imgSlide.Width / 2)) / (imgBack.Width)) * 100
iAnswer = (i / iMax) * 100
Do Until (iPosition = iAnswer - 0.1) Or (iPosition = iAnswer + 0.1)
imgSlide.Left = imgSlide.Left + 0.1
iPosition = ((imgSlide.Left + (imgSlide.Width / 2)) / (imgBack.Width)) * 100
iAnswer = (i / iMax) * 100
Loop
iValue = i
End Property
Property Get Max() As Integer
Max = iMax
End Property
Property Let Max(i As Integer)
iMax = i
End Property
Private Sub UserControl_Initialize()
imgBack.Width = UserControl.Width
UserControl.Height = imgBack.Width
lblTitle.ForeColor = RGB(91, 91, 255)
lblTitle.Left = imgBack.Width / 2 - lblTitle.Width / 2
End Sub
Private Sub UserControl_Resize()
imgBack.Width = UserControl.Width
UserControl.Height = imgBack.Height + 20
lblTitle.Left = imgBack.Width / 2 - lblTitle.Width / 2
End Sub
I am making an Active X slider control, Bul I can't seem the get the slider to position properly on the background, for the slider. I am using two picture controls name picBack and picSlide. Below is my current code. Does anyone have a solution, or can find a problem which I can't see? I have used a timer, so find when the slider is off the edges of the bar. If anyone has either a whole new answer from another example of can find a bug. Mainly in Property Let Value(i as Integer) then it would be really great. Thanx
Option Explicit
Dim xFind As Integer
Private iMax As Integer
Dim blnCheck As Integer
Private iValue As Integer
Private Sub imgSlide_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then xFind = X
End Sub
Private Sub imgSlide_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnCheck = True Then Exit Sub
If Button = 1 Then imgSlide.Move imgSlide.Left + (X - xFind)
End Sub
Private Sub tmrSlider_Timer()
If imgSlide.Left < 0 Then
imgSlide.Left = 0
blnCheck = True
Else
blnCheck = False
End If
If (imgSlide.Left + imgSlide.Width) > imgBack.Width Then
imgSlide.Left = (imgBack.Width - imgSlide.Width)
blnCheck = True
Else
blnCheck = False
End If
End Sub
Property Get Value() As Integer
If iMax < iValue Then iMax = iValue
Value = iValue
End Property
Property Let Value(i As Integer)
If iMax < i Then iMax = i
Dim iPosition As Integer
Dim iAnswer As Integer
iPosition = ((imgSlide.Left + (imgSlide.Width / 2)) / (imgBack.Width)) * 100
iAnswer = (i / iMax) * 100
Do Until (iPosition = iAnswer - 0.1) Or (iPosition = iAnswer + 0.1)
imgSlide.Left = imgSlide.Left + 0.1
iPosition = ((imgSlide.Left + (imgSlide.Width / 2)) / (imgBack.Width)) * 100
iAnswer = (i / iMax) * 100
Loop
iValue = i
End Property
Property Get Max() As Integer
Max = iMax
End Property
Property Let Max(i As Integer)
iMax = i
End Property
Private Sub UserControl_Initialize()
imgBack.Width = UserControl.Width
UserControl.Height = imgBack.Width
lblTitle.ForeColor = RGB(91, 91, 255)
lblTitle.Left = imgBack.Width / 2 - lblTitle.Width / 2
End Sub
Private Sub UserControl_Resize()
imgBack.Width = UserControl.Width
UserControl.Height = imgBack.Height + 20
lblTitle.Left = imgBack.Width / 2 - lblTitle.Width / 2
End Sub