Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21237

[RESOLVED] Trayectory calculation problem.

$
0
0
I am lost ;), far time ago I was capable to resolve things like this, but now I haven't inspiration.

I needs to reposition a form in such way that it is placed far from the mouse position, BUT, it must respond to the mouse movement, positioning this form in the back from the mouse actual trayectory movement.

So if the mouse moves to the left, this form must be back on the right from the actual mouse position.

if the mouse change its trayectory the form must change its position nicely.

rules, no parts of this form be on the current mouse position.

so I have a current mouse position , and an old mouse position. Using a differential (-) will get trayectory, I needs to expand the trayectory far away from the mouse pointer.

until now I have this, But I thinks I am doing it wrong.

Code:


Private Sub PosScreener()
Dim T As POINTAPI
Dim TrX As Double
Dim TrY As Double

Dim ResultLeft As Long
Dim ResultTop As Long
Dim ResultWidth As Long
Dim ResultHeight As Long

ResultWidth = FormScreen.Width / Screen.TwipsPerPixelX
ResultHeight = FormScreen.Height / Screen.TwipsPerPixelY

' Calcula trayectoria.
T.X = m_CursorPos.X - LastKnownMousePositionX
T.Y = m_CursorPos.Y - LastKnownMousePositionY
' Verifica si tiene una trayectoria.
If T.X = 0 And T.Y = 0 Then
    ' No se pudo calcular una trayectoria debido a que el mouse no se ha movido.
    ' Verifica la posición horizontal actual del mouse.
    If m_CursorPos.X * Screen.TwipsPerPixelX > Screen.Width / 2 Then
        ' Del lado derecho de la pantalla.
        T.X = 1
    Else
        ' Del lado izquierdo de la pantalla.
        T.X = -1
    End If
End If
   
If T.X >= 0 And T.Y >= 0 Then
    ' Trayectoria hacia el cuadrante inferior derecho.
   
Else
    If T.X >= 0 And T.Y < 0 Then
        ' Trayectoria hacia el cuadrante superior derecho.
    Else
        If T.X < 0 And T.Y >= 0 Then
            ' Trayectoria hacia el cuadrante inferior izquierdo.
        Else
            ' Trayectoria hacia el cuadrante superior izquierdo.
        End If
    End If
End If

End Sub

someone can helpme with this?

the whole idea is like TAILING the mouse smoothly like a dragon tail.

Viewing all articles
Browse latest Browse all 21237

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>