OVH Cloud OVH Cloud

form transparente

11 réponses
Avatar
bobysmith
Bonjour,
J'aimerai faire un FadeIn de ma fenetre en utilisant la propriété opacity
de 0 à 1.
Cependant lorsque que je cree une boucle for :

Dim i As Byte
For i = 0 To 1
Opacity = i
i = i + 0.1
Sleep(100)
Next

Je n'ai pas le degradé voulu. J'ai seulement la fenetre qui apparait d'un
coup au bout d'un certain tps. J'ai essayé avec des Me.Refresh() ou des
Application.DoEvents() mais rien ni fait.

Si quelqu'un avait la solution ?

1 réponse

1 2
Avatar
ng
lol ok, normal dans Form_Load, la fenetre n'est pas encore visible !

Attention l'événement activated est exécuté plusieurs fois (a chaque
activation et non seulement à la première), il faudra utiliser une variable
private booléenne pour vérifier si la form a deja été affichée (cf mon
code).

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



bobysmith a écrit :

Merci Nicolas,

J'ai compris pourquoi ca ne marchait pas chez moi. Je mettai la
boucle for dans form_load et non dans form_activated.
Ca marche maintenant

Merci encore


"ng" wrote:

Salut,

Je viens de tester sous VS 2002 avec une TransparencyKey blanche
puis noire et le code suivant :

#Region " Gestion AlphaBlend "

Private bShowed As Boolean

Private Sub SetOpacity(ByVal lPercent As Int32)
Me.Opacity = (lPercent / 100)
Call System.Threading.Thread.Sleep(10)
Application.DoEvents()
End Sub

Private Sub Form1_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated
If Not bShowed Then
bShowed = True
Dim i As Int32
For i = 0 To 100
Call SetOpacity(i)
Next
End If
End Sub


Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim i As Int32
For i = 100 To 0 Step -1
Call SetOpacity(i)
Next
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Opacity = 0
End Sub
#End Region

Aucun problème !

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



bobysmith a écrit :

moi je suis Visual.Net 2003

"ng" wrote:

Salut,

Avec un TransparencyKey ca marche tout aussi bien ici (je suis sous
VB2005 Beta).

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



bobysmith a écrit :

Je viens de voir pourquoi ca ne fait pas le FadeIn.
En fait j'ai aussi attribué une TransparencyKey a black. Et si je
supprime cette TransparencyKey eh bien la ca marche !
Alors comment faire pour que Opacity et TransparecyKey marche
ensemble pour faire un FadeIn. A savoir que si je fait plusieurs
bouton avec des Opacity différentes eh bien la ca marche (avec
TransparecyKey actif)

C'est donc un problème de raffraichissement dans la boucle for

Que faire ?


"ng" wrote:

Salut,

Ceci fonctionne très bien chez moi :

Public Class Form1
Private bShowed As Boolean
Private Sub Form1_Activated(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Activated
If Not bShowed Then
bShowed = True
Dim i As Int32
For i = 0 To 100
Me.Opacity = (i / 100)
Call System.Threading.Thread.Sleep(10)
Application.DoEvents()
Next
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
Me.Opacity = 0
End Sub
End Class


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



bobysmith a écrit :

Bonjour,
J'aimerai faire un FadeIn de ma fenetre en utilisant la
propriété opacity de 0 à 1.
Cependant lorsque que je cree une boucle for :

Dim i As Byte
For i = 0 To 1
Opacity = i
i = i + 0.1
Sleep(100)
Next

Je n'ai pas le degradé voulu. J'ai seulement la fenetre qui
apparait d'un coup au bout d'un certain tps. J'ai essayé avec
des Me.Refresh() ou des Application.DoEvents() mais rien ni
fait.

Si quelqu'un avait la solution ?














1 2