Rends transparente puis opaque fenetre affichée(de windows), blague

Contenu du snippet

Bon ben envoyer la a quelqu'un, puis ses fenêtre vont devenir petit a petit transparente, et revenir opaque, et ainsi de suite

Source / Exemple :


Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000

'déclaration des apis

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 Function GetForegroundWindow Lib "user32" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim hWd As Long
Dim opacite As Integer
Dim up As Boolean

Sub Main()'boucle de début du programme(dans projet, option, objet de démarage mettre main
up = False
opacite = 255
Do While True 'boucle a l'infinie
    If up = False Then
        If opacite <= 0 Then'controle pour que si l'opacité est a 0, on remonte
            up = True
            opacite = opacite + 1
        Else
            opacite = opacite - 1
        End If
    Else
            If opacite >= 255 Then
            up = False
            opacite = opacite - 1
        Else
            opacite = opacite + 1
        End If
    End If
    hWd = GetForegroundWindow 'on récupère le handle de la fenêtre active
    DoEvents
    Call SetWindowOpacity(hWd, opacite) on mets l'opacité a celle ci
    Sleep 10 ' une petite pause pour pas que ça aille trop vite tout de même :)
Loop
End Sub

Public Function SetWindowOpacity(ByVal hWnd As Long, Opacité As Integer) As Boolean' fonction pour rendre une fenêtre
' transparente, trouvée ici http://www.vbfrance.com/article.aspx?ID=8961

    Dim Ret As Long

    On Error GoTo PROC_ERREUR

    Ret = GetWindowLong(hWnd, GWL_EXSTYLE)

    Opacité = Abs(Opacité)
    If Opacité > 255 Then Opacité = 255

    If Opacité = 255 Then
        Ret = Ret And Not WS_EX_LAYERED
        SetWindowLong hWnd, GWL_EXSTYLE, Ret
        SetLayeredWindowAttributes hWnd, 0, 0, LWA_ALPHA
    Else
        Ret = Ret Or WS_EX_LAYERED
        SetWindowLong hWnd, GWL_EXSTYLE, Ret
        SetLayeredWindowAttributes hWnd, 0, Opacité, LWA_ALPHA
    End If
    
    If Err Then GoTo PROC_ERREUR

    SetWindowOpacity = True
    Exit Function

PROC_ERREUR:
    SetWindowOpacity = False

End Function

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.