views:

363

answers:

2

Can any body tell me how to handle events for System tray in windows.

I mean, when some body clicks on the system tray icon then I want to check whether to enable the application or not. Is there any way to capture events corresponding to system tray click.

+1  A: 

In a .NET Forms Application the System Tray control { NotifyIcon } provides following Events to check what you want to achieve:

  • Click
  • DoubleClick
  • MouseClick
  • MouseDoubleClick

You can put the logic into these event handlers.

I hope this one helps out!

Shaharyar
Yea, I tried it, but the problem is that event will be fired only when the application icon is clicked in icon bar, but I want to handle click on any of the application in the icon bar, and check whether to allow that application to focus or not.Any comments?
Ashwani K
Oh! Then you want to handle all behaviors in the icon tray, no matter where you click? Right? Let me see if I can find something!
Shaharyar
Yea I want handle all
Ashwani K
A: 

CodeProject about NotifyIcon
MSDN about NotifyIcon

NotifyIcon class events:

Click Occurs when the user clicks the icon in the status area.
DoubleClick Occurs when the user double-clicks the icon in the status notification area of the taskbar.
MouseDown Occurs when the user presses the mouse button while the pointer is over the icon in the status notification area of the taskbar.
MouseMove Occurs when the user moves the mouse while the pointer is over the icon in the status notification area of the taskbar.
MouseUp Occurs when the user releases the mouse button while the pointer is over the icon in the status notification area of the taskbar.

nihi_l_ist