Visual Basic - Evento "MouseOut"

Life is soft - evento anual de software empresarial
 
Vista:

Evento "MouseOut"

Publicado por Edgardo (16 intervenciones) el 04/09/2006 16:35:00
Hola a todos, mi pregunta es que quiero saber como hago para que me tome un evento cuando el mouse se salga del formulario. Todo bien cuando lo muevo o clickeo al form, pero lo que quiero es poner una rutina cuando se salga el cursor del formulario. Cualquier ayuda es bienvenida. Gracias y saludos.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Evento

Publicado por LLE (2 intervenciones) el 05/09/2006 15:05:55
Hola una forma que conozco es usando el Api WindowsFromPoint y un Timer.

Coloca un Timer1 y pegá esto:

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long

Private Type POINTAPI
X As Long
Y As Long
End Type
Dim posicion As POINTAPI, retHwnd As Long
Private flag As Boolean

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseArriba
End Sub

Private Sub Timer1_Timer()
MouseOut
End Sub

Private Sub dibujar(Colorback As Long, SCaption As String, _
ColorFont As Long, ElForm As Form)

Dim izq As Single, arriba As Single
flag = False
With ElForm
.BackColor = Colorback
.ForeColor = ColorFont
End With

izq = (ElForm.ScaleWidth - TextWidth(SCaption)) / 2
arriba = (ElForm.ScaleHeight - TextHeight(SCaption)) / 2

ElForm.CurrentX = izq
ElForm.CurrentY = arriba

ElForm.Print SCaption

End Sub

Private Sub Form_Load()
With Me
.AutoRedraw = True
.FontName = "MS Sans Serif"
.Font.Size = 10
End With

dibujar vbWhite, "Hola", vbBlack, Me

Timer1.Interval = 10
End Sub

Private Sub Mover()
If flag = False Then
dibujar vbBlack, "Mundo", vbWhite, Me
flag = True
End If
End Sub

Private Sub MouseOut()

GetCursorPos posicion

retHwnd = WindowFromPoint(posicion.X, posicion.Y)

If retHwnd <> hWnd And flag = True Then
dibujar vbWhite, "Hola", vbBlack, Me
End If
End Sub

Private Sub MouseArriba()
flag = False
Mover
Timer1.Enabled = True
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Mover
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar