Bonjour,
Voici un code pas très bien structuré mais qui permet d'afficher un icon dans le tray avec un info-bulle et un ballon
Option Explicit
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NotifIcon) As Boolean
Private Const MESS_ADD As Long = &H0 '// Pour ajouter une icone
Private Const MESS_MODIFY As Long = &H1 '// Pour modifier une icone
Private Const MESS_DELETE As Long = &H2 '// Pour effacer une icone
Private Const FLAG_MESSAGE As Long = &H1 '// Pour récupérer les évènements de la souris (clique, déplacement ...)
Private Const FLAG_ICON As Long = &H2 '// Pour affiche l'icone (sinon espace vide)
Private Const FLAG_TIP As Long = &H4 '// Pour avoir le ToolTip
Private Const FLAG_BULLE As Long = &H10 '// Pour afficher une bulle
Private Const CB_MOUSEMOVE As Long = &H200 '// Pour que lors d'un évènement souris sur l'icone, Form_MouseMove soit lancée
Private Type NotifIcon
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 128
dwState As Long
dwStateMask As Long
szInfo As String * 256
uTimeout As Long
szInfoTitle As String * 64
dwInfoFlags As Long
End Type
Private IconData As NotifIcon
Private Enum Icon
None = 0
Information = 1
Warning = 2
Critical = 3
Tray = 4
End Enum
Private Sub CreateIcon(Icon As Picture, Optional ToolTip As String)
IconData.cbSize = Len(IconData)
IconData.hWnd = Form1.hWnd
IconData.uID = vbNull
IconData.uFlags = FLAG_ICON Or FLAG_MESSAGE Or FLAG_TIP
IconData.uCallbackMessage = CB_MOUSEMOVE
IconData.hIcon = Icon
IconData.szTip = ToolTip & vbNullChar
Shell_NotifyIcon MESS_ADD, IconData
End Sub
Private Sub DestroyIcon()
Shell_NotifyIcon MESS_DELETE, IconData
End Sub
Private Sub Bollon(ByVal Title As String, ByVal Text As String, ByVal Icon As Icon)
IconData.uFlags = IconData.uFlags Or FLAG_BULLE
IconData.szInfo = Text & vbNullChar
IconData.szInfoTitle = Title & vbNullChar
IconData.dwInfoFlags = Icon
Shell_NotifyIcon MESS_MODIFY, IconData
IconData.uFlags = FLAG_ICON Or FLAG_MESSAGE Or FLAG_TIP
End Sub
Private Sub Form_Load()
Call CreateIcon(Me.Icon, "Toto")
Call Ballon("AAA", "BBB", Critical)
End Sub
ChrB