MouseLeave "rebuscado" para Label (para text seria mas directo por el Hwn)
Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Text1.Appearance = Label1.Appearance
Text1.BorderStyle = Label1.BorderStyle
Text1.Top = Label1.Top
Text1.left = Label1.left
Text1.Height = Label1.Height
Text1.Width = Label1.Width
Text1.Visible = False
Label1.BackColor = vbBlack
Label1.ForeColor = vbWhite
Label1.Alignment = 2
Label1.FontBold = True
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
Dim TR1 As RECT
Dim TR2 As RECT
Dim Left1 As Integer
Dim Left2 As Integer
Dim Top1 As Integer
Dim Top2 As Integer
Dim Point As POINTAPI
GetCursorPos Point
Call GetWindowRect(Text1.hwnd, TR1)
Call GetClientRect(Text1.hwnd, TR2)
Left1 = TR1.left
Left2 = TR1.left + (Label1.Width / 15)
Top1 = TR1.Bottom - TR2.Bottom
Top2 = TR1.Bottom - TR2.Bottom + (Label1.Height / 15)
If Point.X > Left1 And Point.X < Left2 And Point.Y > Top1 And Point.Y < Top2 Then
Label1.BackColor = vbRed
Else
Label1.BackColor = vbBlack
End If
End Sub
Nota: puede servir tambien para saber si en una aplicacion externa a la nuestra estan pasando el mouse sobre un control .
Saludos