Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

bug transparence et textbox

1 réponse
Avatar
Jer
Bonjour

j'ai une petite appli qui se lance au démarrage avec un effet de
transparence.
Tout va bien sauf le textbox qui est tout noir. Si je cache le textbox et
que je le fais apparaitre après la transparence, celui reste caché, il faut
cliquer dessus pour qu'il apparaisse (en flat et en borderstyle =0 au lieu
de flat et borderstyle=1).

Le problème vient apparemment de la transparence car cela fonctionne bien
sans. Mais je n'arrrive pas à cerner le problème pour y remédier.

Voici le code de transparence :

Function Settranslucid(ByVal hWnd As Long, SetAs As Boolean, bAlpha As Byte)
lret = GetWindowLong(hWnd, GWL_EXSTYLE)


If SetAs = True Then
lret = lret Or WS_EX_LAYERED
Else
lret = lret And Not WS_EX_LAYERED
End If
SetWindowLong hWnd, GWL_EXSTYLE, lret
SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
End Function

qui est appelé par: settranslucid me.hwnd, true, 200

merci pour votre aide

Jer

1 réponse

Avatar
Quasimodo
Jer wrote :
Bonjour

j'ai une petite appli qui se lance au démarrage avec un effet de
transparence.
Tout va bien sauf le textbox qui est tout noir. Si je cache le textbox et
que je le fais apparaitre après la transparence, celui reste caché, il faut
cliquer dessus pour qu'il apparaisse (en flat et en borderstyle =0 au lieu
de flat et borderstyle=1).

Le problème vient apparemment de la transparence car cela fonctionne bien
sans. Mais je n'arrrive pas à cerner le problème pour y remédier.

Voici le code de transparence :

Function Settranslucid(ByVal hWnd As Long, SetAs As Boolean, bAlpha As Byte)
lret = GetWindowLong(hWnd, GWL_EXSTYLE)


If SetAs = True Then
lret = lret Or WS_EX_LAYERED
Else
lret = lret And Not WS_EX_LAYERED
End If
SetWindowLong hWnd, GWL_EXSTYLE, lret
SetLayeredWindowAttributes hWnd, 0, bAlpha, LWA_ALPHA
End Function

qui est appelé par: settranslucid me.hwnd, true, 200

merci pour votre aide

Jer



Bonjour,
allez voir sur le site http://www.mentalis.org/index2.shtml, vous
trouverez votre bonheur (leur tools est génial pour les api), sur
google il y a des samples sur lesquel vous pouvez comparer
(ex:http://www.vbfrance.com/code.aspx?ID$621).
Voici un exemple adapté de celui de l'API-GUID
(http://www.mentalis.org/agnet/apiguide.shtml).
Utiliser une forme + un commandbutton et une textbox pour l'exemple
ci-dessous, copier le code dans la forme et c'est caisse.
----------------------------------------------------------------------------------------------------------------------------
Private m_bTrans As Boolean

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 Settranslucid(ByVal hWnd As Long, SetAs As Boolean)

Dim Ret As Long

Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
If SetAs Then
Ret = Ret Or WS_EX_LAYERED
Else
Ret = Ret And Not WS_EX_LAYERED
End If
'Set the window style to 'Layered'
SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
'Set the opacity of the layered window to 128
SetLayeredWindowAttributes Me.hWnd, 0, 128, LWA_ALPHA

End Sub

Private Sub Command1_Click()

m_bTrans = Not m_bTrans
Settranslucid Me.hWnd, m_bTrans

End Sub

Private Sub Form_Load()

m_bTrans = False

End Sub
----------------------------------------------------------------------------------------------------------------------------

@+ Quaz

--
This is an automatic signature of MesNews.
Site : http://mesnews.no-ip.com