Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Little icons

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
How do you add little icons to the task bar at the bottom right - like messenger in c# .net??
 
If you are using .NET Framework 1.1 there is NotifyIcon control that you can add to the main form like any another control.
Here is an example with the double click event and the icon loaded as embeded resource from the assembly.
You could add the conetxt menu and tool tip depending on the application status.
Code:
public class DogForm : System.Windows.Forms.Form
{
    private System.Windows.Forms.NotifyIcon notifyIcon1;
     static void Main() 
        {
            DogForm frm= new DogForm();
            // Set the icon that will be displayed in systray
            notifyIcon1.Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("myAssembly.watchdogsystrayicon.ico"), 16, 16);
            
            Application.Run(frm);
        }
    public DogForm()
    {
        //...
    	this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
    	//...
    	
    	// Handle the DoubleClick event to activate the form
        notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
        
    	 // Set the ContextMenu property - the menu that will appear when the systray icon is right clicked.
         // notifyIcon1.ContextMenu = this.contextMenu1;
         // Tool tip example
          notifyIcon.Text = Application.ProductName + " is running for " + Environment.UserName;
	  notifyIcon1.Visible = true;

         
    }
    private void notifyIcon1_DoubleClick(object Sender, EventArgs e) 
        {
            // Show the form when the notify icon is double-clicked.
            if (this.WindowState == FormWindowState.Minimized)
               this.WindowState = FormWindowState.Normal;
            this.Activate();
    }

}
obislavu
 
transparent,
Take a look at this link. It contains exactly what you need!

JC

_________________________________________________
To get the best response to a question, read faq222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top