Click here to Skip to main content
12,950,027 members (81,346 online)
Click here to Skip to main content
Articles » Languages » C# » How To » Downloads


117 bookmarked
Posted 6 May 2007

Creating a Tasktray Application

, 23 Sep 2007 CPOL
How to create an application that consists primarily of a tasktray icon
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace TaskTrayApplication
    public class TaskTrayApplicationContext : ApplicationContext
        NotifyIcon notifyIcon = new NotifyIcon();
        Configuration configWindow = new Configuration();

        public TaskTrayApplicationContext()
            MenuItem configMenuItem = new MenuItem("Configuration", new EventHandler(ShowConfig));
            MenuItem exitMenuItem = new MenuItem("Exit", new EventHandler(Exit));

            notifyIcon.Icon = TaskTrayApplication.Properties.Resources.AppIcon;
            notifyIcon.DoubleClick += new EventHandler(ShowMessage);
            notifyIcon.ContextMenu = new ContextMenu(new MenuItem[] { configMenuItem, exitMenuItem });
            notifyIcon.Visible = true;

        void ShowMessage(object sender, EventArgs e)
            // Only show the message if the settings say we can.
            if (TaskTrayApplication.Properties.Settings.Default.ShowMessage)
                MessageBox.Show("Hello World");

        void ShowConfig(object sender, EventArgs e)
            // If we are already showing the window meerly focus it.
            if (configWindow.Visible)

        void Exit(object sender, EventArgs e)
            // We must manually tidy up and remove the icon before we exit.
            // Otherwise it will be left behind until the user mouses over.
            notifyIcon.Visible = false;


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United Kingdom United Kingdom
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170524.1 | Last Updated 23 Sep 2007
Article Copyright 2007 by [ICR]
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid