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
| Private Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal uType As Long, _
ByVal wLanguageID As Long, _
ByVal lngMilliseconds As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Sub CommandButton1_Click()
ActiveCell.Activate
MsgBoxTemporaire (2000)
End Sub
Private Sub MsgBoxTemporaire(durée As Long)
' Affiche une boite de message temporaire
'
' Arguments : durée [in] Durée d'affichage en millisecondes
'
Const msg As String = "Msgbox avec tempo de 2s"
Const title As String = "Popup"
Const timeOut As Integer = 32000
Dim retval As Long
Dim boutons As Long
boutons = vbSystemModal + vbYesNoCancel + vbInformation 'au minimum : modal
retval = MessageBoxTimeout(FindWindow(vbNullString, title), msg, title, boutons, 0, durée) 'en ms
If retval = timeOut Then
MsgBox "Pas de réponse, tempo atteinte"
ElseIf retval = vbYes Then
MsgBox "Oui"
ElseIf retval = vbNo Then
MsgBox "Non"
ElseIf retval = vbCancel Then
MsgBox "Annuler"
End If
End Sub |
Partager