Fenêtres vraiment transparentes

cs_Clem Messages postés 282 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 12 février 2007 - 30 mars 2002 à 11:49
mWaAtR Messages postés 49 Date d'inscription jeudi 30 août 2001 Statut Membre Dernière intervention 28 avril 2010 - 30 mars 2002 à 21:01
J'ai remarqué que sur Win2000 et WinXP, il y avait la posibilité de rendre transparente une fenêtre.
Sur WinAmp 3 et sur TransXP (http://transxp.3utilities.com).
Et j'ai aussi trouvé l'API, mais je n'arrive pas à l'utiliser dans VB (Les constantes sont inconnues).
Voici l'adresse http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/windows_1p6b.asp
Pouvez-vous m'aider ?

5 réponses

mWaAtR Messages postés 49 Date d'inscription jeudi 30 août 2001 Statut Membre Dernière intervention 28 avril 2010
30 mars 2002 à 16:39
Voilà les constantes qui te manquent (le reste est dans la visionneuse d'API).
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000

Trouvées sur : http://camalot.virtualave.net/

Si tu ne t'en sort pas avec cette fonction, redis moi, c'est pas difficile à faire fonctionner.
0
cs_Clem Messages postés 282 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 12 février 2007
30 mars 2002 à 19:21
Merci beaucoup de bien vouloir m'aider.

Voilà ou j'en suis maintenant :
Private Declare Function SetLayeredWindowAttributes Lib "User32.dll" (ByVal hwnd As Long, COLORREF As OLE_COLOR, bAlpha As Byte, dwFlags As Any) As Boolean
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)

Private Sub Form_Load()
SetWindowLong Me.hwnd, GWL_STYLE, WS_EX_LAYERED
Me.Caption = SetLayeredWindowAttributes(Me.hwnd, RGB(255, 255, 255), 128, LWA_ALPHA)
End Sub

A chaque foix le nom de la fenêtre (Le resultat de l'appel API) est Faux, donc que ça ne marche pas.
Je pense que ça vient de SetWindowLong (Quels sont les paramètres à utiliser ?).
Le reste a l'air bon d'après moi (Je suis pas un pro de conversion C++>VB / VB>C++)
Merci.
0
mWaAtR Messages postés 49 Date d'inscription jeudi 30 août 2001 Statut Membre Dernière intervention 28 avril 2010
30 mars 2002 à 19:45
Voilà ma fonction :

Option Explicit

Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private 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 SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags 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
Public Sub WndSetOpacity(ByVal hWnd As Long, Optional ByVal crKey As Long vbBlack, Optional ByVal Alpha As Byte 255, Optional ByVal byAlpha As Boolean = True)
'hWnd  : hWnd de la fenêtre à rendre transparente
'crKey : Couleur à rendre transparente si ByAlpha=False
'Alpha : Transparence 0-255 0=transparent 255=Opaque si ByAlpha=true
  Dim ExStyle As Long
  ExStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
  ExStyle = ExStyle Or WS_EX_LAYERED
  Call SetWindowLong(hWnd, GWL_EXSTYLE, ExStyle)
  SetLayeredWindowAttributes hWnd, crKey, Alpha, IIf(byAlpha, LWA_ALPHA, LWA_COLORKEY)
End Sub
0
mWaAtR Messages postés 49 Date d'inscription jeudi 30 août 2001 Statut Membre Dernière intervention 28 avril 2010
30 mars 2002 à 19:47
J'ressaye, j'sais pas s'qui à merder...

Option Explicit

Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private 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 SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags 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
Public Sub WndSetOpacity(ByVal hWnd As Long, Optional ByVal crKey As Long vbBlack, Optional ByVal Alpha As Byte 255, Optional ByVal byAlpha As Boolean = True)
'hWnd : hWnd de la fenêtre à rendre transparente
'crKey : Couleur à rendre transparente si ByAlpha=False
'Alpha : Transparence 0-255 0=transparent 255=Opaque si ByAlpha=true
Dim ExStyle As Long
ExStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
ExStyle = ExStyle Or WS_EX_LAYERED
Call SetWindowLong(hWnd, GWL_EXSTYLE, ExStyle)
SetLayeredWindowAttributes hWnd, crKey, Alpha, IIf(byAlpha, LWA_ALPHA, LWA_COLORKEY)
End Sub
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
mWaAtR Messages postés 49 Date d'inscription jeudi 30 août 2001 Statut Membre Dernière intervention 28 avril 2010
30 mars 2002 à 21:01
J'ai encore un peu améliorer la fonction et l'ai mise dans les sources...

http://forum.vbfrance.com/article.asp?Val=3799
0
Rejoignez-nous