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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| '/// APIs : Déclarations et constantes
Declare Function timeSetEvent& Lib "winmm.dll" ( _
ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, _
ByVal dwUser As Long, ByVal uFlags As Long)
Declare Function timeKillEvent& Lib "winmm.dll" (ByVal uID As Long)
Const TIME_PERIODIC = &H1
Const TIME_CALLBACK_FUNCTION = &H0
'/// Portée au niveau Projet
Public EnCours1 As Boolean
Public EnCours2 As Boolean
'/// Portée au niveau Module
Dim hTimer1 As Long
Dim hTimer2 As Long
Dim Couleur1 As Long
Dim Couleur2 As Long
'**************
Sub LaunchUSFs()
UserForm1.Show vbModeless
UserForm2.Show vbModeless
End Sub
'######################################################
'######################################################
'######################################################
Sub TimerEvent1(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
Static bool As Boolean
With UserForm1.CommandButton1
If bool Then
.BackColor = 12106214
Else
.BackColor = 12379351
End If
End With
bool = Not bool
End Sub
Sub TimerStart1(Optional dummy As Byte)
Dim frequenceTime As Long
Couleur1 = UserForm1.CommandButton1.BackColor
frequenceTime = 250
hTimer1 = timeSetEvent(frequenceTime, 0, AddressOf TimerEvent1, 0, TIME_PERIODIC Or TIME_CALLBACK_FUNCTION)
End Sub
Sub TimerStop1(Optional dummy As Byte)
If hTimer1 > 0 Then
timeKillEvent hTimer1
UserForm1.CommandButton1.BackColor = Couleur1
End If
End Sub
'######################################################
'######################################################
'######################################################
Sub TimerEvent2(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
Static bool As Boolean
With UserForm2.CommandButton1
If bool Then
.BackColor = 10288887
Else
.BackColor = 15849925
End If
End With
bool = Not bool
End Sub
Sub TimerStart2(Optional dummy As Byte)
Dim frequenceTime As Long
Couleur2 = UserForm2.CommandButton1.BackColor
frequenceTime = 250
hTimer2 = timeSetEvent(frequenceTime, 0, AddressOf TimerEvent2, 0, TIME_PERIODIC Or TIME_CALLBACK_FUNCTION)
End Sub
Sub TimerStop2(Optional dummy As Byte)
If hTimer2 > 0 Then
timeKillEvent hTimer2
UserForm2.CommandButton1.BackColor = Couleur2
End If
End Sub
'######################################################
'######################################################
'######################################################
Sub Traitement1(Optional dummy As Byte)
If Not EnCours1 Then
Call EtatCroixFermeture(UserForm1, False)
Call TimerStart1
EnCours1 = True
End If
'une suite d'instructions et de macros
End Sub
Sub Traitement2(Optional dummy As Byte)
If Not EnCours2 Then
Call EtatCroixFermeture(UserForm2, False)
Call TimerStart2
EnCours2 = True
End If
'une suite d'instructions et de macros
End Sub |
Partager