Use this:


VB Code:
  1. Private WithEvents TI As cTrayIcon
  2.  
  3. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  4.     If UnloadMode = vbFormControlMenu Then
  5.         'I don't want to terminate the app
  6.        
  7.         Set TI = New cTrayIcon
  8.         With TI
  9.             .SetPct pctTray
  10.             .CreateIcon "This is my app"
  11.         End With
  12.         Me.Hide
  13.         Cancel = 1
  14.     End If
  15.    
  16. End Sub
  17.  
  18.  
  19. Private Sub TI_TrayIconDoubleCLick()
  20.     TI.DeleteIcon
  21.     Set TI = Nothing
  22.     Me.Show
  23. End Sub
  24.  
  25. Private Sub Form_Unload(Cancel As Integer)
  26.     TI.DeleteIcon
  27.     Set TI = Nothing
  28.                    
  29. End Sub

pctTray is a picturebox (invisible) with the icon you want to show in the Systray.