Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB code to VBScript - fade in fade out of splash screen

Status
Not open for further replies.

hoskinsm

IS-IT--Management
Feb 18, 2008
5
US
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

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
 
VBScript doesn't have timer controls like VB6 does and it cannot utilise the Windows API.
I don't know the answer to your problem but I would give up trying to adapt this code to VBScript.

Dave.
 
Thanks Dave....I have no problem giving up this particular code, it was just the sample I found but in VB...and I have been scouring every forum for vbscript code examples I can build upon but no luck....any suggestions on how I can fade in fade out a splash screen in vbscript?
 
You could try posting in the correct forums:

VBScript: Forum329
VB: Forum222

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Geoff,

You are right, for my original post with VB code and not scripting, if the other vbscripters are like me, we know nothing of vb code....but I have found most VB guys know vbscript. Sorry for the mis-posting and thank you all for your assistance.
 
I don't think it's possible to set window transparency without going through the windows API, so it looks like this is a lost cause.
Good luck anyway!
Dave.
 
Dave,
Thank you, unless I receive any other replies, I will consider this to be one of those "out of my control" items.

I appreciate everyones input....the forum is very useful and you guys rock.

Thanks,
Moe
 
well this is still the vbA forum. Not VB

You may get more answers in either of the forums I linked to

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 




Aye!

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top