Ashwani K
Ashwani K

Reputation: 8000

How to handle events for icon tray in windows using C#

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.

Upvotes: 1

Views: 2795

Answers (2)

0x49D1
0x49D1

Reputation: 8704

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.

Upvotes: 1

Faizan S.
Faizan S.

Reputation: 8644

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!

Upvotes: 3

Related Questions