Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everybody. Can you give me some suggestion of how can I display two or more icons in systray using C# and WPF(or WinForms) like Office 2010 beta's "Send a smile/frown" function? These icons should have the ability to handle user's click/doubleclick, not just an icon displayed there.

Thanks a lot.
Posted
Updated 11-Mar-10 20:50pm
v2

Its not very difficult to add multiple Icons in system tray using c#.
We can also handle the events . First of all you create two(or more) NotifyIcon in your application.

private System.Windows.Forms.NotifyIcon NotifyIcon1;
private System.Windows.Forms.NotifyIcon NotifyIcon2;


After that you have to initialize the icons as follows

MIDL
// Initializing
NotifyIcon1 = new System.Windows.Forms.NotifyIcon();
NotifyIcon2 = new System.Windows.Forms.NotifyIcon();
// Add the icon images
NotifyIcon1 .Icon = new System.Drawing.Icon("YourImage1.ico"); 
NotifyIcon2 .Icon = new System.Drawing.Icon("YourImage2.ico"); 
// Add text
NotifyIcon1 .Text = "text1";
NotifyIcon2 .Text = "text2";
// subscribe events here
NotifyIcon1 .MouseDown +=new System.Windows.Forms.MouseEventHandler(NotifyIcon1 _MouseDown); 

You can also set the context menus in the NotifyIcon.
Set the visibility according to your requirement.
If you are using wpf , you should add the reference System.Windows.Forms to your project.

Thanks,
Vineeth
 
Share this answer
 
v2
Vineeth, your suggestion is very useful, thank you very much!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900