Cree una DLL para controlar la posicion del mouse.
Lo que hago con esta DLL es mantener al cursor del mouse dentro de el form impidiendo que salga.
La DLL es llamada a traves de un timer (intervalo 100) de esta manera:
Dim crs As Cursor.Cursor1
crs = New Cursor.Cursor1
crs.cursorp(Cursor.Current.Position.X, Cursor.Current.Position.Y, Me.Left, Me.Left, Me.Top, Me.Top + Me.Height)
crs = Nothing
Cuando se sale a la izquierda o derecha el mouse vuelve sin problemas.
El problema esta cuando el cursor es < al me.top o > al me.top+me.heigh (parte de abajo), es en ese momento se produce un pequeño retardo y la aplicacion es sensitiva al mouse, un pequeño retardo devuelve resultados no esperados haciendo que la tarea que la app realiza termine realizandola mal.
Alguien puede ayudarme en este asunto?
Gracias, dejo a continuacion el codigo de la dll.
Código:
Public Class Cursor1 Inherits System.Windows.Forms.Form Function cursorp(ByVal x As Integer, ByVal y As Integer, ByVal li As Integer, ByVal ld As Integer, ByVal tp As Integer, ByVal td As Integer) If x < li + 14 Then Dim point As System.Drawing.Point point.X = Math.Round(li + 1) point.Y = Math.Round(y) Cursor.Current.Position = point Exit Function End If If x > li + 542 Then Dim point As System.Drawing.Point point.X = Math.Round(li + 539) point.Y = Math.Round(y) Cursor.Current.Position = point Exit Function End If If y < tp Then Dim point As System.Drawing.Point point.X = Math.Round(x) point.Y = Math.Round(td / 2) Cursor.Current.Position = point Exit Function End If If y > td Then Dim point As System.Drawing.Point point.X = Math.Round(x) point.Y = Math.Round(td / 2) Cursor.Current.Position = point Exit Function End If End Function End Class