'This code is based om a submission to PSC by Ed Preston
Public Enum FadingSpeed
[Fade Slow] = 1
[Fade Medium] = 2
[Fade Fast] = 4
[Fade Very Fast] = 8
End Enum
'Properties
Private Const pnEnabled As String = "Enabled"
Private Const pnFadeIn As String = "FadeInSpeed"
Private Const pnFadeOut As String = "FadeOutSpeed"
Private Const pnOpacity As String = "Opacity"
Private myEnabled As Boolean
Private myFadeInSpeed As FadingSpeed
Private myFadeOutSpeed As FadingSpeed
Private myOpacity As Long
'Private variables
Private Alpha As Long
Private ParhWnd As Long
Private Internal As Boolean
'Events
Public Event FadeInReady()
Public Event FadeOutReady()
'Win API
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 GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex 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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function OSVersion Lib "kernel32" Alias "GetVersion" () As Long
Private Const RequiredVersion As Long = 5
'Win Consts
Private Const WS_EX_LAYERED As Long = &H80000
Private Const GWL_EXSTYLE As Long = -20
Private Const LWA_ALPHA As Long = 2
Public Property Let Enabled(ByVal nwEnabled As Boolean)
Attribute Enabled.VB_Description = "Sets/returns whether the Control is operable."
myEnabled = (nwEnabled <> False) And WindowsIsSuitable
PropertyChanged pnEnabled
End Property
Public Property Get Enabled() As Boolean
Enabled = myEnabled
End Property
Public Sub FadeIn()
If myEnabled Then
For Alpha = Alpha To (myOpacity / 100) * 255 Step myFadeInSpeed