VB Code:
  1. Private Type NOTIFYICONDATA
  2.     cbSize As Long
  3.     hWnd As Long
  4.     uId As Long
  5.     uFlags As Long
  6.     ucallbackMessage As Long
  7.     hIcon As Long
  8.     szTip As String * 64
  9. End Type
  10.  
  11. Private Const NIM_ADD = &H0
  12. Private Const NIM_MODIFY = &H1
  13. Private Const NIM_DELETE = &H2
  14. Private Const NIF_MESSAGE = &H1
  15. Private Const NIF_ICON = &H2
  16. Private Const NIF_TIP = &H4
  17.  
  18. Private Const WM_LBUTTONDBLCLK = &H203
  19. Private Const WM_LBUTTONDOWN = &H201
  20. Private Const WM_RBUTTONUP = &H205
  21.  
  22. Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
  23. Dim TrayI As NOTIFYICONDATA
  24. Private Sub Form_Load()
  25.     TrayI.cbSize = Len(TrayI)
  26.     'Set the window's handle (this will be used to hook the specified window)
  27.     TrayI.hWnd = pichook.hWnd
  28.     'Application-defined identifier of the taskbar icon
  29.     TrayI.uId = 1&
  30.     'Set the flags
  31.     TrayI.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
  32.     'Set the callback message
  33.     TrayI.ucallbackMessage = WM_LBUTTONDOWN
  34.     'Set the picture (must be an icon!)
  35.     TrayI.hIcon = imgIcon(2).Picture
  36.     'Set the tooltiptext
  37.     TrayI.szTip = "Recent" & Chr$(0)
  38.     'Create the icon
  39.     Shell_NotifyIcon NIM_ADD, TrayI
  40.  
  41.     Me.Hide
  42. End Sub
  43. Private Sub Form_Unload(Cancel As Integer)
  44.     'remove the icon
  45.     TrayI.cbSize = Len(TrayI)
  46.     TrayI.hWnd = pichook.hWnd
  47.     TrayI.uId = 1&
  48.     Shell_NotifyIcon NIM_DELETE, TrayI
  49.     End
  50. End Sub
  51. Private Sub mnuPop_Click(Index As Integer)
  52.     Select Case Index
  53.         Case 0
  54.             MsgBox "KPD-Team 1998" + Chr$(13) + "URL: [url]http://www.allapi.net/[/url]" + Chr$(13) + "E-Mail: [email][email protected][/email]", vbInformation + vbOKOnly
  55.         Case 2
  56.             Unload Me
  57.     End Select
  58. End Sub
  59. Private Sub pichook_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  60.     Msg = X / Screen.TwipsPerPixelX
  61.     If Msg = WM_LBUTTONDBLCLK Then
  62.         'Left button double click
  63.         mnuPop_Click 0
  64.     ElseIf Msg = WM_RBUTTONUP Then
  65.         'Right button click
  66.         Me.PopupMenu mnuPopUp
  67.     End If
  68. End Sub
  69. Private Sub Timer1_Timer()
  70.     Static Tek As Integer
  71.     'Animate the icon
  72.     Me.Icon = imgIcon(Tek).Picture
  73.     TrayI.hIcon = imgIcon(Tek).Picture
  74.     Tek = Tek + 1
  75.     If Tek = 3 Then Tek = 0
  76.     Shell_NotifyIcon NIM_MODIFY, TrayI
  77. End Sub

or see http://www.vb-world.net/tips/tip61.html