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
| Dim MyBitMap As Bitmap = New Bitmap(250, 20)
Dim msn As New XihSolutions.DotMSN.Messenger()
Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
Dim Date_fin As Date
Dim Jours_restants, Heures_restantes, Minutes_restantes, Secondes_restantes As Long
Dim Heures_cumulées, Minutes_cumulées, Secondes_cumulées As Long
Date_fin = "08/09/2007 06:00:00"
Jours_restants = DateDiff(DateInterval.Day, Now(), Date_fin)
Heures_cumulées = DateDiff(DateInterval.Hour, Now(), Date_fin)
Heures_restantes = Heures_cumulées - Jours_restants * 24
Minutes_cumulées = DateDiff(DateInterval.Minute, Now(), Date_fin)
Minutes_restantes = Minutes_cumulées - Heures_cumulées * 60
Secondes_cumulées = DateDiff(DateInterval.Second, Now(), Date_fin)
Secondes_restantes = Secondes_cumulées - Minutes_cumulées * 60
Me.Text = Jours_restants & " jours " & Heures_restantes & " heures " & Minutes_restantes & " minutes " & Secondes_restantes & " secondes"
'Affichage Notify icon
Call UpdateNotiFyIcon(lblTemps_restant.Text)
End Sub
Private Sub UpdateNotiFyIcon(ByVal texte As String)
Dim newIcon As Icon = Drawing.Icon.FromHandle(MyBitMap.GetHicon)
Call UpdateBitmap(texte)
NotifyIcon1.Icon = newIcon
newIcon.Dispose()
End Sub
Private Sub UpdateBitmap(ByVal texte As String)
Dim g As Graphics = Graphics.FromImage(MyBitMap)
Dim police = New System.Drawing.Font("Arial", 8)
g.Clear(Color.White)
g.DrawString(texte, police, New SolidBrush(Color.Black), 2, 2)
PictureBox1.Image = MyBitMap
g.Dispose()
End Sub |
Partager