Les Snippets

Connexion

Rendre une form transparente / translucide

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 12/01/2010 14:31:58 et initié par PCPT [Liste]
Vue : 1422
Catégorie(s) : API, Trucs & Astuces, Graphique
Langages dispo pour ce code :
- VB6
- VBA
- VB 2005, VB 2008
- C# 2.x, C# 3.x
- Voir tous les langages pour ce code snippet



Langage : VBA
Date ajout : 12/01/2010
Posté par PCPT [Liste]
Private Const GWL_EXSTYLE As Long = (-20)
Private Const LWA_ALPHA As Long &H2
Private Const WS_EX_LAYERED As Long &H80000
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As StringByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As LongByVal nIndex As Long) As  Long
Private Declare Function SetLayeredWindowAttributes Lib  "user32" (ByVal hwnd As LongByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As  Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As LongByVal nIndex As Long, ByVal dwNewLong As Long) As  Long
Public Sub SetFormTransparence(ByVal sUserformCaption As String, ByVal bTransparent As Boolean)
    Dim lHwnd  As Long
    Dim lStyle As Long
    lHwnd = FindWindowA("Thunder" IIf(Application.Version Like "8*""X""D") & "Frame", sUserformCaption)
    If lHwnd <> Then
        lStyle = GetWindowLong(lHwnd, GWL_EXSTYLE)
        If lStyle <> (lStyle Or WS_EX_LAYERED) Then Call SetWindowLong(lHwnd,  GWL_EXSTYLE, lStyle Or WS_EX_LAYERED)
        
        Call SetLayeredWindowAttributes(lHwnd,  0&, IIf(bTransparent, 127, 255), LWA_ALPHA)
    End If
End Sub
Remarque :
applicable depuis le caption du userform
toujours à partir de windows 2000

Snippets en rapport avec : Form, Alpha, Transparente, Translucide



Codes sources en rapport avec : Form, Alpha, Transparente, Translucide

{Visual Basic, VB6, VB.NET, VB 2005} ENCORE UNE FORM AEROGLASS SANS API AVEC EFFET FLOU
Voila c'est un composant à glisser dans une form pour la transformer en aeroglass. le code est en p...

{C / C++ / C++.NET} DESSINER UNE IMAGE TRANSPARENTE (WIN32)
Ce code montre comment dessiner une image avec de la transparence, mais de manière non uniforme (les...

{Visual Basic, VB6, VB.NET, VB 2005} FORM TRANSPARENTE
Voila une Form rendu transparente grâce à une capture d'écran projetée en background : bon, c'est u...

{Visual Basic, VB6, VB.NET, VB 2005} RENDRE UNE FENÊTRE (FORM) TRANSLUCIDE (COULEUR PARAMÉTRABLE)
Voila, comme promis, un exemple de création de fenêtre translucide. Cette création est réalisée v...

{Visual Basic, VB6, VB.NET, VB 2005} FEUILLE TRANSPARENTE
positionne une feuille transparente sur la totalité de l'écran déactive les touches génantes ctrl...

{Visual Basic, VB6, VB.NET, VB 2005} FEUILLE TRANSPARENTE
Ce code permet de render une feuille transparente , de ne voir que les controls. ...

{Visual Basic, VB6, VB.NET, VB 2005} FENETRE TRANSLUCIDE (MODIF DE LA VERSION DE MAX12)
J'ai repris le code de l'archive "FEUILLE TRANSLUCIDE (VERSION OFFICIEL)" de max12, et j'y est ajout...

{C# / C#.NET} LANCER UNE FEUILLE FILLE MDI UNE ET UNE SEULE FOIS
Bonjour. Cette application va résoudre un petit peu un problème que j'ai rencontré dans les forms M...

{JAVA / J2EE} J2ME APPLICATION MATHÉMATIQUES FINANCIÈRES
calcul des intérêts composé simple , annuité.... cété une application pr valider un module de java ...

{C# / C#.NET} HORLOGE FLOTTANTE SUR LE BUREAU AVEC CHOIX FUSEAU
World Small Clock, c'est le premier programme que j'ai réellement finalisé. Il permet l'affichage de...