View Single Post
Old Apr 2nd, 2005, 9:47 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
I can't be held responsible for tasteless misuse of this code

So put this in your form:
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
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 Sub Form_Activate()
Dim Alpha As Byte
Dim Delay As Single
Do
    Delay = Timer
    Do While (Timer - Delay) < 0.01
        DoEvents
    Loop
    Alpha = Alpha + 5
    SetLayeredWindowAttributes Me.hWnd, 0, Alpha, LWA_ALPHA
Loop Until Alpha = 255
End Sub

Private Sub Form_Load()
    Dim Ret As Long
    Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
    Ret = Ret Or WS_EX_LAYERED
    SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
End Sub
Rory is offline   Reply With Quote