Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long,
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long,
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey
As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000
Dim m_lAlpha
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim pos As POINTAPI
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As
Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As
Long
Private Sub Form_Load()
Dim lStyle As Long
lStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, lStyle
SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_ALPHA
End Sub
Private Sub Timer1_Timer()
GetCursorPos pos
'move pos.x * 15 + 10 * 15, pos.y * 15 + 20 * 15
Text1.Text = pos.x * 15 + 10 * 15 - 20
Text2.Text = pos.y * 15 + 20 * 15 - 20
Text3.Text = Me.Left
Text4.Text = Me.Top
If pos.x * 15 + 10 * 15 - 100 > Me.Left And pos.x * 15 + 10 * 15 - 100 < Me.Left + Me.Width Then
Text5.Text = "X in"
Else
Text5.Text = "X out"
End If
If pos.y * 15 + 20 * 15 - 100 > Me.Top And pos.y * 15 + 20 * 15 - 100 < Me.Top + Me.Height Then
Text6.Text = "Y in"
Else
Text6.Text = "Y out"
End If
If pos.x * 15 + 10 * 15 - 100 > Me.Left And pos.x * 15 + 10 * 15 - 100 < Me.Left + Me.Width And pos.y *
15 + 20 * 15 - 100 > Me.Top And pos.y * 15 + 20 * 15 - 100 < Me.Top + Me.Height Then
Timer2.Enabled = True
Timer3.Enabled = False
Else
Timer2.Enabled = False
Timer3.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
m_lAlpha = m_lAlpha + 15
If (m_lAlpha > 255) Then
m_lAlpha = 255
Timer1.Enabled = True
Timer2.Enabled = False
Else
SetLayeredWindowAttributes Me.hWnd, 0, m_lAlpha, LWA_ALPHA
End If
End Sub
Private Sub Timer3_Timer()
m_lAlpha = m_lAlpha - 15
If (m_lAlpha < 155) Then
m_lAlpha = 155
Else
SetLayeredWindowAttributes Me.hWnd, 0, m_lAlpha, LWA_ALPHA
End If
End Sub