Hello all,
Thank you in advance to anyone who can assist me.
I am using a VBScript to perform so very simple routines using wmi. I would like to incorporate a Splash Screen which Fades In and Fades out. I have not been able to find any existing code for VBScript to do this...but I was able to find VB code to perform this. However, I am using VBScript and wondering if anyone can tell me how to incorporate the VB code within the script.
Here is the code, I rather than firing the code on a buton click event, I plan to have it run on the Windows_onload
Thank you in advance to anyone who can assist me.
I am using a VBScript to perform so very simple routines using wmi. I would like to incorporate a Splash Screen which Fades In and Fades out. I have not been able to find any existing code for VBScript to do this...but I was able to find VB code to perform this. However, I am using VBScript and wondering if anyone can tell me how to incorporate the VB code within the script.
Here is the code, I rather than firing the code on a buton click event, I plan to have it run on the Windows_onload
Code:
Option Explicit
DefLng A-Z
' API declarations...
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
' Local variables used in controlling fade in
Private StartValue As Long, EndValue As Long, Increment As Long
Private Const Opaque As Long = 255
Private Const Transparent As Long = 150
Private Const Invisible As Long = 0
Private CurrentState As Long
Private Sub cmdFadeOut_Click()
' Set to go from opaque to transparent.
StartValue = Opaque
EndValue = Transparent
Increment = -3
tmr.Enabled = True
cmdfadeout.Enabled = False
End Sub
Private Sub Form_Load()
CurrentState = Opaque
End Sub
Private Sub tmr_Timer()
Static BeenHereB4 As Boolean
Dim lStyle As Long
If Not BeenHereB4 Then
lStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, lStyle
BeenHereB4 = True
End If
CurrentState = CurrentState + Increment
If CurrentState < 0 Then CurrentState = 0
If CurrentState > 255 Then CurrentState = 255
SetLayeredWindowAttributes Me.hwnd, 0, CurrentState, LWA_ALPHA
If (Increment > 0 And CurrentState >= EndValue) _
Or (Increment < 0 And CurrentState <= EndValue) _
Then
tmr.Enabled = False
Beep
If EndValue = Invisible Then
Unload Me
End If
End If
End Sub