how to get the icon in system tray when the main window is closed

kanak

Newcomer
Joined
Jan 9, 2005
Messages
16
hi all

i want when my window form get closed it shud place a icon on the system tray .. can anyone tell me how to do it ... and also how to add the menu when the user right click at the icon ...

i dont want it to display on the taskbar but as a icon in the system tray
 
kanak said:
hi all

i want when my window form get closed it shud place a icon on the system tray .. can anyone tell me how to do it ... and also how to add the menu when the user right click at the icon ...

i dont want it to display on the taskbar but as a icon in the system tray

Hi

For the systemtray icon, use the NotifyIcon control, and set the visibility property to false if you don't want the icon to be in the system tray at all times.
In the form_Closing event of your form, put code something along the lines of:
Visual Basic:
        e.Cancel = True
        Me.Hide()
        NotifyIcon.Visible = True

This will hide the form, and make the sys tray icon visible.

As for the menu, look at the ContextMenu control - create the menu and remember to add it to the system tray icon (by using the NotifyIcon's ContextMenu property ;)

Hope this helps :)
 
Last edited:
Back
Top