' Déclarations API
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'renvoie les styles de la fenêtre
Public Const GWL_STYLE As Long = -16
'renvoie les styles étendus de la fenêtre
Public Const GWL_EXSTYLE As Long = -20
' Pour la transparence
Public Const WS_EX_LAYERED = &H80000
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Boolean
Public Const LWA_COLORKEY = &H1
Public Const LWA_ALPHA = &H2
' Active la transparence d'une fenetre (nécessite Win2k ou +)
' Renvoie FALSE si la transparence ne peut pas etre appliquée
Public Function EnableTransparency(ByVal hWnd As Long) As Boolean
On Error GoTo Err
SetWindowLong hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
EnableTransparency = True
Exit Function
Err:
EnableTransparency = False
End Function
' Change la valeur de la transparence (de 0 : transparent à 255 : opaque)
Public Function ChangeTransparency(ByVal hWnd As Long, ByVal Alpha As Byte) As Boolean
On Error GoTo Err
SetLayeredWindowAttributes hWnd, 0, Alpha, LWA_ALPHA
ChangeTransparency = True
Exit Function
Err:
ChangeTransparency = False
End Function
' Supprime la transparence
Public Function DisableTransparency(ByVal hWnd As Long)
On Error Resume Next
SetWindowLong hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) - WS_EX_LAYERED
End Function
Le 30/12/2006 par MadMatt : Legere modif
Seul les admins et l'auteur du code lui même peuvent modifier ce code.