Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Make my program in System Tray with C#

Posted on 2004-09-13
5
Medium Priority
?
254 Views
Last Modified: 2010-08-05
I want to write my program but use it from the system tray . I don't kow how to make that system tray part. I also want to know how to make a right click menu on that system tray icon.
0
Comment
Question by:drtoto82
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 19

Accepted Solution

by:
Fahad Mukhtar earned 172 total points
ID: 12051410
0
 
LVL 5

Assisted Solution

by:tzxie2000
tzxie2000 earned 164 total points
ID: 12052514
put an notifyicon on the form

put an contextmenu on the form and design your menu

assign notifyicon.contextmenu to the contextmenu you add

all is done
0
 

Assisted Solution

by:happy_coder
happy_coder earned 164 total points
ID: 12056118
here is the code needed to make a notifyicon and the context menu needed for it

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

namespace WindowsApplication4
{
      /// <summary>
      /// Summary description for Form1.
      /// </summary>
      public class Form1 : System.Windows.Forms.Form
      {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.Container components = null;

            
            private NotifyIcon notifyIcon;

            
            private MenuItem menuItem;

            
            private ContextMenu contextMenu;


            public Form1()
            {
                  //
                  // Required for Windows Form Designer support
                  //
                  InitializeComponent();

                  //
                  // TODO: Add any constructor code after InitializeComponent call
                  //
            }

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose( bool disposing )
            {
                  if( disposing )
                  {
                        if (components != null)
                        {
                              components.Dispose();
                        }
                  }
                  base.Dispose( disposing );
            }

            #region Windows Form Designer generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                  //
                  // Form1
                  //
                  this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
                  this.ClientSize = new System.Drawing.Size(292, 266);
                  this.Name = "Form1";
                  this.Text = "Form1";
                  this.Load += new System.EventHandler(this.Form1_Load);

            }
            #endregion

            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                  Application.Run(new Form1());
            }

            private void Form1_Load(object sender, System.EventArgs e)
            {
                  menuItem = new MenuItem();
                  contextMenu = new ContextMenu();
                  notifyIcon = new NotifyIcon();

                  menuItem.Index = 0;
                  menuItem.Text = "E&xit";
                  menuItem.Click += new EventHandler(menuItem_Click);

                   contextMenu.MenuItems.Add(menuItem);

                  notifyIcon.Icon = new Icon("app.ico");

                  notifyIcon.ContextMenu = contextMenu;

                  notifyIcon.DoubleClick += new EventHandler(notifyIcon_DoubleClick);

                  notifyIcon.Visible = true;

            }
            
            private void Exit_OnClick()
            {
                  Application.Exit();
            }
            
            private void menuItem_Click(object sender, EventArgs e)
            {
                  Application.Exit();
            }
            
            private void notifyIcon_DoubleClick(Object Sender, EventArgs e)
            {
                  
                  if (this.WindowState == FormWindowState.Minimized)
                        this.WindowState = FormWindowState.Normal;
   
                  this.Activate();
            }


      }
}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question