C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » General »

Easy Tray Icon for our projects


Posted Date: 25 Aug 2009    Resource Type: Code Snippets    Category: General
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 10



Description :


Creating Tray icon is very simple in .net.
By using the following code we can creat the Tray Icon for our Projects.

Namespace part

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;


Coding part

namespace WindowsApplication1
{
public partial class Form1 : Form
{
private System.Windows.Forms.NotifyIcon MyNotifyIcon;
private System.Windows.Forms.ContextMenu MyContextMenu;
private System.Windows.Forms.MenuItem MyMenuItem1;
private System.Windows.Forms.MenuItem MyMenuItem2;
private System.Windows.Forms.MenuItem MyMenuItem3;

public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.MyNotifyIcon = new NotifyIcon(new System.ComponentModel.Container());
this.MyContextMenu = new System.Windows.Forms.ContextMenu();
this.MyMenuItem1 = new System.Windows.Forms.MenuItem();
this.MyMenuItem2 = new System.Windows.Forms.MenuItem();
this.MyMenuItem3 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();


this.MyNotifyIcon.ContextMenu = this.MyContextMenu;
this.MyNotifyIcon.Icon = new System.Drawing.Icon("MyIcon.ico");
this.MyNotifyIcon.Text = "My Tray Icon";
this.MyNotifyIcon.Visible = true;
this.MyContextMenu.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.MyMenuItem1,
this.MyMenuItem2,
this.MyMenuItem3});
this.MyMenuItem1.Index = 0;
this.MyMenuItem1.Text = "Exit";
this.MyMenuItem1.Click += new
System.EventHandler(this.menuItem1_Click);
this.MyMenuItem2.Index = 1;
this.MyMenuItem2.Text = "Hide";
this.MyMenuItem2.Click += new
System.EventHandler(this.menuItem2_Click);
this.MyMenuItem3.Index = 2;
this.MyMenuItem3.Text = "Show";
this.MyMenuItem3.Click += new
System.EventHandler(this.menuItem3_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(504, 365);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}

private void menuItem1_Click(object sender, System.EventArgs e)
{
Close();
}

private void menuItem2_Click(object sender, System.EventArgs e)
{
this.Visible = false;
}

private void menuItem3_Click(object sender, System.EventArgs e)
{
this.Visible = true;
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}


By
Nathan



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Tray Icon for our projects  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Values removed from priority queue using c++
Previous Resource: Create the multiset object using c++
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use