ARTICLE

Tray Bar Application

Posted by Edwin Lima Articles | Windows Forms C# October 30, 2001
This is a very simple C# application which implements those very familiar Windows applications with a tray Icon.
Reader Level:
Download Files:
 

Description:

This is a very simple C# application which implements those very familiar Windows applications with a tray Icon . To implement this application I used C# and VS.NET beta 2.

First, create a new Windows Application on VS.NET. In the automatically added Form set the property ShowInTaskBar to false and WindowsState property as Minimized.

Add a NotifyIcon and a ContextMenu Control to your form. In the ContextMenu Control add two MenuItem and set the Text property of each one to Hello and Exit respectively.

For the NotifyIcon control that you have just added to the form you must set the property Icon to any *.ico file in your file system.

Now add code to the events on click of every MenuItem of the context Menu:

private void menuItem1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Hello World. This a tray icon application. Bye!");
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
// exits the application
Application.Exit();
}

The context menu should be poped up by your application when you click the right button of the mouse over the tray icon that will appear once you execute the application. The combination of the properties, WindowsState as Minimized and the ShowInTaskBar as false, avoid that your application appears in the Task Bar and the main form is minimized when the application starts. In this way, the only thing that is visible to the application user is the Windows tray icon.

That's it. Compile the source code and enjoy it!

Login to add your contents and source code to this article
post comment
     

Hey good one man... this helped in my real time projects/... Thanks Buddy

Posted by Chitkaran Singh Nov 23, 2007
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts