i think this will do what you want it to..
here is what this dos
a ball follows your mouse when a menu item is hovered over
you can put the code on formmove and it will move when the mouse is anywhere on the form.. and i think you knwo the possibilities from there
Code:
Option Explicit
Dim Xp1, Xp2, Yp1, Yp2, destXPoint, destYpoint As Integer
Dim XPoint As Integer
Dim YPoint As Integer
Dim Slope As Double
Dim YIntercept As Double
Dim UpDown As Boolean
Private Sub CoordinateCalc()
UpDown = (Xp1 = Xp2)
If Not UpDown Then
Slope = (Yp1 - Yp2) / (Xp1 - Xp2)
YIntercept = Slope * Xp1 - Yp1
End If
End Sub
Private Sub MoveBall(x1 As Integer, x2 As Integer, y1 As Integer, y2 As Integer, dest As Integer)
If (x1 = x2) And (y1 = y2) Then Exit Sub
Xp1 = x1
Xp2 = x2
Yp1 = y1
Yp2 = y2
destXPoint = dest
destYpoint = Yp2
Call CoordinateCalc
imgBall.Visible = True
TmrDrop.Enabled = True
End Sub
Private Sub Form_Initialize()
XPoint = 3
YPoint = 3
End Sub
Private Sub Form_Load()
Call OpenDB
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgBall.Visible = False
End Sub
Private Sub imgAdministrator_Click()
Unload Me
frmMaitenance.Show
End Sub
Private Sub imgAdministrator_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call MoveBall(XPoint, 2970, YPoint, 5505, 2970)
End Sub
Private Sub imgScrap_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call MoveBall(XPoint, 7375, YPoint, 6000, 7375)
End Sub
Private Sub TmrDrop_Timer()
imgBall.Left = imgBall.Left + 50 * Sgn(Xp2 - Xp1) ' -50 or +0 or +50 depending on situation
If UpDown Then
imgBall.Top = imgBall.Top + 50 * Sgn(Yp2 - Yp1)
Else
imgBall.Top = imgBall.Left * Slope - YIntercept
End If
If Not UpDown Then
Select Case Sgn(Xp2 - Xp1)
Case -1 ' Moves backwards
If imgBall.Left <= Xp2 Then
imgBall.Left = Xp2
imgBall.Top = Yp2
TmrDrop.Enabled = False
End If
Case 1 ' Moves forwards
If imgBall.Left >= Xp2 Then
imgBall.Left = Xp2
imgBall.Top = Yp2
TmrDrop.Enabled = False
End If
End Select
Else ' UpDown
Select Case Sgn(Yp2 - Yp1)
Case -1 ' Moves up
If imgBall.Top <= Yp2 Then
imgBall.Left = Xp2
imgBall.Top = Yp2
TmrDrop.Enabled = False
End If
Case 1 ' Moves down
If imgBall.Top >= Yp2 Then
imgBall.Left = Xp2
imgBall.Top = Yp2
TmrDrop.Enabled = False
End If
End Select
End If
End Sub
Private Sub tmrPosition_Timer()
XPoint = imgBall.Left
YPoint = imgBall.Top
End Sub
//this was possible with help of Yonatan