|
| |||||||||
| Tags: c application, contextmenu, notifyicon, system tray, visual studio |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| How to Place Your C# Application in the System Tray?
Can we place the C# Application in the System Tray?? I am trying to do lot of things but not getting succeeded. Does anyone know the steps that are involved in specifying that an application is to be minimized to the Tray.?? Also how to allow the user to restore the application by double-clicking the icon. Since I am new to the C# the detailed information will be most welcomed. Please help me solving the problem as soon as possible.
__________________ "Let us remember that our interest is in concord, not conflict, and that our real eminence rests in the victories of peace, not those of war." -McKinley |
|
#2
| ||||
| ||||
| Re: How to Place Your C# Application in the System Tray?
If you want to place your C# Application in the System Tray, then you will have to use an event handler for the form's Resize event. Using this event handler for Resize event will hide the application when it's minimized. After doing this it will not appear on the task bar. The following coding can be useful for doing that : Code: private void Form1_Resize(object sender, System.EventArgs ea)
{
if (FormWindowState.Minimized == WindowState)
Hide();
}
__________________ The FIFA Manager 2009 PC Game |
|
#3
| ||||
| ||||
| Re: How to Place Your C# Application in the System Tray?
As you said that you are new for the C# application, here is the Step-by-step process for placing the C# application in the System Tray :
Code: private void notifyIcon1_DoubleClick(object sender,
System.EventArgs ea)
{
Show();
WindowState = FormWindowState.Normal;
} |
|
#4
| ||||
| ||||
| Re: How to Place Your C# Application in the System Tray?
You will also have to check the steps that is involved with adding a context menu to the icon :
__________________ Grand Theft Auto 4 PC Video Game |
|
#5
| ||||
| ||||
| Re: How to Place Your C# Application in the System Tray?
Sometimes you will have to do something more for the notifyIcon1_DoubleClick like this : Show(); WindowState = FormWindowState.Normal; Activate(); You can also add a form closing event to your form like this one : Code: private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
RestoreIcon.Visible = false;
} |
|
#6
| |||
| |||
| Re: How to Place Your C# Application in the System Tray?
I think that you will have to create an icon first. You can use the Favicon Generator for creating the icons. Looks of an icons are not important, so make it anyway. You can place that icon anywhere and for that you will have to edit the path so that it suits your needs. Here is the code for that : Code: namespace SystemTrayTest
{
public partial class Form1 : Form
{
public NotifyIcon notifyIcon1 = new NotifyIcon();
public Form1()
{
InitializeComponent();
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
this.notifyIcon1.Visible = true;
this.notifyIcon1.Text = "KlausurServer v 2.1";
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.notifyIcon1 = new NotifyIcon();
this.notifyIcon1.Visible = false;
try
{
notifyIcon1.Icon = new System.Drawing.Icon(@"D:\klausurServer.ico");
this.notifyIcon1.Click += new System.EventHandler(notifyIcon1_Click);
}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}
}
private void notifyIcon1_Click(object sender, System.EventArgs e)
{
this.ShowInTaskbar = true;
this.notifyIcon1.Visible = false;
this.WindowState = FormWindowState.Normal;
}
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to Place Your C# Application in the System Tray?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| System slow down with gray bitdefender system tray icon | Jigya L. | Networking & Security | 4 | 18-02-2011 07:40 PM |
| How to use the System Tray in Java? | - Empty Shell - | Software Development | 4 | 16-02-2010 04:50 AM |
| Tray 2.5 application not able to work under Windows 7 | Sawan123 | Operating Systems | 5 | 13-02-2010 05:05 AM |
| pc tools tray application | Anthony | Vista Help | 4 | 21-09-2007 09:20 PM |
| System Tray Icons | MyD0j0 | Windows XP Support | 8 | 11-05-2007 07:59 AM |