Article ID: 113948
Article Last Modified on 10/29/2003
' Add the following to the general declarations section:
Dim Mouse_Button As Integer
Dim Mouse_X As Single
Dim PicFrame As Integer
Sub Form_Load ()
Timer1.Enabled = False
Timer1.Interval = 10
Image1.Picture = LoadPicture("C:\VB\ICONS\ELEMENTS\EARTH.ICO")
PicFrame = 2 * Screen.TwipsPerPixelY
Image1.Top = 0
Image1.Left = 0
Picture1.Height = Image1.Height + PicFrame
End Sub
' Enter the following two lines as one, single line of code:
Sub Image1_MouseDown (Button As Integer, Shift As Integer, X As Single,
Y As Single)
Timer1.Enabled = True
Mouse_Button = Button
Mouse_X = Image1.Left + X
End Sub
' Enter the following two lines as one, single line of code:
Sub Image1_MouseMove (Button As Integer, Shift As Integer, X As Single,
Y As Single)
Mouse_Button = Button
Mouse_X = Image1.Left + X
End Sub
' Enter the following two lines as one, single line of code:
Sub Image1_MouseUp (Button As Integer, Shift As Integer, X As Single,
Y As Single)
Timer1.Enabled = False
Mouse_Button = Button
Mouse_X = Image1.Left + X
End Sub
Sub Timer1_Timer ()
Dim TempLeft As Integer
If Mouse_Button = 1 Then
TempLeft = Image1.Left
TempLeft = Mouse_X - TempWidth / 2
If TempLeft + Image1.Width > Picture1.Width Then
TempLeft = Picture1.Width - Image1.Width - PicFrame
End If
If TempLeft < 0 Then TempLeft = 0
End If
If Image1.Left <> TempLeft Then Image1.Left = TempLeft
End Sub
Additional query words: 3.00 slider
Keywords: KB113948