1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| Option Explicit
Public Const RELIEF = 1
Public Const ENCADREMENT = 2
Public CtlPasséDessus As Boolean 'on voit si on est passé ou non sur le controle
Public iTim As Integer 'compte les secondes du timer lancé
Public Const CouleurFondOriginale = &H8000000F
Public Const CouleurFondTemporaire = &H80FFFF 'nimporte quelle couleur sauf la CouleurFondOriginale, ne se voit pas a l'écran, car sinon le label n'affiche plus le texte contenu
Public Sub AspectBouton(Frm As Form, Ctl As Control, Tim As Timer)
If CtlPasséDessus = False Then 'passage de la souris sur le controle, on envoi l'aspect bouton
CtlPasséDessus = True
Call Ombrage(Frm, Ctl, ENCADREMENT, 10, &H80000011) 'gris foncé
Call Ombrage(Frm, Ctl, RELIEF, 10, &H80000005) '&H80000005) blanc vista '&H80000009) 'blanc W2000
Tim.Enabled = True
Else 'une seconde après l'aspect bouton, on revient à l'aspect original du controle
iTim = iTim + 1 'on suppose que l'intervalle du Timer est à 1000 ms
If iTim = 2 Then
Call Ombrage(Frm, Ctl, ENCADREMENT, 10, &H8000000F) 'gris normal
Call Ombrage(Frm, Ctl, RELIEF, 10, &H8000000F) 'gris normal
Tim.Enabled = False
CtlPasséDessus = False '1 seconde après le passage de la souris, retour a l'aspect initial du contrôle
iTim = 0
End If
End If
End Sub
'Ombrer un controle, notamment lors des survols de souris sur un lbl clicable
Public Sub Ombrage(Feuille As Form, Ctrl As Control, Effet As Integer, OmbreLarg As Integer, OmbreCoul As Long)
Dim CouleurOmbre As Long
Dim LargeurOmbre As Integer
Dim Largeur As Integer
Dim Taille As Integer
LargeurOmbre = OmbreLarg
CouleurOmbre = OmbreCoul
Largeur = Feuille.DrawWidth
Taille = Feuille.ScaleMode
Feuille.DrawWidth = 1
Select Case Effet
Case ENCADREMENT
Ctrl.BackColor = CouleurFondTemporaire
Feuille.Line (Ctrl.Left + LargeurOmbre, Ctrl.Top + LargeurOmbre)- _
Step(Ctrl.Width - 1, Ctrl.Height - 1), CouleurOmbre, BF
Ctrl.BackColor = CouleurFondOriginale
Case RELIEF
Ctrl.BackColor = CouleurFondTemporaire
Feuille.Line (Ctrl.Left - LargeurOmbre, Ctrl.Top - LargeurOmbre)- _
Step(Ctrl.Width - 1, Ctrl.Height - 1), CouleurOmbre, BF
Ctrl.BackColor = CouleurFondOriginale
End Select
Feuille.DrawWidth = Largeur
Feuille.ScaleMode = Taille
End Sub |
Partager