Option Explicit
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 Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
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 LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000
Private m_lAlpha As Long
Private Sub cmdOK_Click()
tmr.Enabled = True
End Sub
Private Sub Form_Load()
m_lAlpha = 255
End Sub
Private Sub tmr_Timer()
If (m_lAlpha = 255) Then
Dim lStyle As Long
lStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, lStyle
End If
Dim lAlpha
m_lAlpha = m_lAlpha - 25
lAlpha = m_lAlpha
If (lAlpha < 0) Then
lAlpha = 0
End If
SetLayeredWindowAttributes Me.hwnd, 0, lAlpha, LWA_ALPHA
If (m_lAlpha < 0) Then
Unload Me
End If
End Sub