maval
XLDnaute Barbatruc
Bonsoir
Est-il possible d'avoir la date et l'heure sur la barredes titres d'un userform
Merci d'avance
Est-il possible d'avoir la date et l'heure sur la barredes titres d'un userform
Merci d'avance
Private Sub UserForm_Initialize()
Caption = Date & " " & Time
End Sub
Dim temps
Sub auto_close()
On Error Resume Next
Application.OnTime temps, Procedure:="majHeure", Schedule:=False
End Sub
Sub afficheform()
UserForm1.Show
End Sub
Sub majHeure()
UserForm1.Caption = "Nous somme le:" & " " & Format(Date, "dddd dd mmmm yyyy") & " " & "Il est" & " " & Format(Now, "hh:mm:ss")
temps = Now + TimeValue("00:00:1")
Application.OnTime temps, "majHeure"
End Sub
Option Explicit
Public prochaine_heure
Public Userform1OK As Boolean
Sub afficher_heure()
If Userform1OK Then UserForm1.Caption = Format(Now(), "ddd dd-mm-yyyy hh:mm:ss")
prochaine_heure = Now + TimeValue("00:00:01")
Application.OnTime prochaine_heure, "afficher_heure"
End Sub
Sub stop_afficher_heure()
Application.OnTime prochaine_heure, "afficher_heure", Schedule:=False
End Sub
Option Explicit
Private Sub UserForm_Initialize()
Userform1OK = True
afficher_heure
End Sub
Private Sub UserForm_Terminate()
stop_afficher_heure
Userform1OK = False
End Sub
Declare Function GetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function FindWindowA Lib "User32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Sub SupprimerFermeture(USF As UserForm)
Dim hWnd As Long
hWnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", USF.Caption)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
SupprimerFermeture Me
End Sub
Bonjour Mapomme, Geli,
Déjà merci a tous les deux de votre participation. mais j'ai deux questions à posé car je ne connais pas la réponse.
1°- Pourquoi le curseur prend les mouvements des secondes "Clignote"?
2°- J'avais mis un code pour supprimer la croix dans la barre des titres et les deux codes "Date & heure et supprimer la croix" apparemment ne font pas bon ménage ensemble?
Le code pour supprimer la croix
Dans le module 1:
Dans le module UserForm1:Code:Declare Function GetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Declare Function SetWindowLongA Lib "User32" _ (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Declare Function FindWindowA Lib "User32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Code:Public Sub SupprimerFermeture(USF As UserForm) Dim hWnd As Long hWnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _ "X", "D") & "Frame", USF.Caption) SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF End Sub Private Sub CommandButton1_Click() Unload Me End Sub Private Sub UserForm_Initialize() SupprimerFermeture Me End Sub
Voilà si quelqu'un a une idée je suis preneur
Bon dimanche à tous