Click here to Skip to main content
11,433,997 members (57,538 online)
Click here to Skip to main content

Cinchoo - Simplified Windows Tray Application Development

, 9 Nov 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Easy to create and use windows system tray applications

Contents

1. Introduction

Cinchoo is the application framework for .NET. One of the main functionalities it provides to the users is application configuration management. Application configuration is the information that application reads and/or writes at run-time from the source.

One another important feature it offers to the developers community is the unified, generic application host to build and run application in different modes. Code once, run the application as either Console, Windows, WPF, Windows Service or Windows Tray application.

In this article, I'm going to illustrate how to use this library to create Windows Systems Tray application. It is a simpler, fluent model for configuring everything about your tray application in one place. Making it as library letting you to concentrate yourself on the core development tasks. Cinchoo provides a clean and easy API to develop and run Windows systems tray applications.

2. Requirement

The application host library is written in C# for the .NET 4.0 Framework. It is part of Cinchoo framework, which is a great library with lot of features like Configuration Management, common ApplicationHost, Shell features etc.

3. "Hello World!" Sample

Lets begin by looking into a simple example of a windows systems tray application displaying 'Hello World!' tooltip text. 

Download the latest Cinchoo binary here. (Nuget Command: Install-Package Cinchoo)

  • Open VS.NET 2010 or higher
  • Create a sample VS.NET (.NET Framework 4) Console Application project
  • Add reference to Cinchoo.Core.dll
  • Use the Cinchoo.Core namespace
  • Copy and paste the below application host object

Listing 3.1 Defining ApplicationHost object

[ChoApplicationHost]
public class HelloWorldAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.TooltipText = "Hello World!";
    }
}

The code above illustrates about defining ApplicationHost object. First thing define a ApplicationHost (ex. HelloWorldAppHost) class from ChoApplicationHost, it indicates that this object is an ApplicationHost object. And it must be decorated with ChoApplicationHostAttribute to complete the definition.

In this example, we override ApplyGlobalApplicationSettingsOverrides method. In there, we instruct the application to run as Tray Application by setting TurnOn member of TrayApplicationBehaviourSettings object to true. Set the TooltipText value to "Hello World!", this will display the message when you mouse over the tray icon.

Listing 3.2 Main Method

class Program
{
    static void Main(string[] args)
    {
        ChoApplication.Run(args);
    }
}

We start by calling ChoApplication.Run() method in the main entry of the application. That all. All the heavy lifting of configuring, running the application as tray application is done by the library under the hood. Now your application is tray application enabled application. Lets try for yourself.

4. Defining Application Host Object

4.1 ChoApplicationHostAttribute

All application host objects must be decorated by ChoApplicationHostAttribute. An application must have atleast one application host object defined. Cinchoo framework will discover them at the application startup. 

4.2 ChoApplicationHost

All application host objects must be derived from ChoApplicationHost class. By default, it provides basic wire frame of running tray application without making any customization. Some cases, you may want to customize the way you want. In such cases, override nessasary overrides in them. An application must have one application host object defined either in the entry assembly or referenced assemblies. In this object, you can override number of methods for your needs to customize the tray application.

4.2.1 ApplyGlobalApplicationSettingsOverrides() Method

When implemented in a derived class, executes when a application is launched. In here, you have option to override tray application configuration parameters to customize it. Please refer section TrayApplicationBehaviourSettings for more information.

4.2.2 AfterNotifyIconConstructed() Method

When implemented in a derived class, executes when a application runs in Tray application mode. In this method, you can change the tray icon properies. Please refer section ChoNotifyIcon section for more information.

4.2.3 OnTrayAppAboutMenuClicked() Method

When implemented in a derived class, executes when user clicks the 'About' menu item from the context menu. In here, you can display the product information of your application.

4.2.4 OnTrayAppExitMenuClicked() Method

When implemented in a derived class, executes when user clicks the 'Exit' menu item from the context menu. In here, you can perform any cleanup action of your application.

4.2.5 OnTrayAppHelpMenuClicked() Method

When implemented in a derived class, executes when user clicks the 'Help' menu item from the context menu. In here, you can display help information for your application.

4.2.6 OnTrayAppOpenMenuClicked() Method

When implemented in a derived class, executes when user clicks the 'Open' menu item from the context menu. By default, Cinchoo framework will open the main window of your application, if any specified. This default behaviour can be overriable to perform any custom actions. 

4.2.7 MainWindowObject Property

It is a property returns the main window of your application. Default is null. In this case, your application is windowless tray application. This property can be overridable to return either System.Windows.Forms.Form or System.Windows.Window object.

4.2.8 ApplicationObject Property

This property mainly used for WPF application. It returns an object of System.Windows.Application object.

5. Configuration

5.1 TrayApplicationBehaviourSettings

This is easiest way to customize your tray application. Either override the ApplyGlobalApplicationSettingsOverrides() method in your Application Host object or open the ChoCoreFrx.xml configuration file to manipulate this object properties. Cinchoo framework uses them to customize the tray application before launching them.

5.1.1 TurnOn

Gets or sets the turn on switch the Tray Application.

Listing 5.1.1.1 Set TurnOn programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.BalloontipText = "Hello World!";
    }
}

Listing 5.1.1.2 Set TurnOn via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify the boolean value in 'turnOn' attribute under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="true" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon />
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.2 BalloonTipText

Gets or sets the text to display on the balloon tip associated with the NotifyIcon.

Listing 5.1.2.1 Set BalloonTipText programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.BalloontipText = "Hello World!";
    }
}

Listing 5.1.2.2 Set BalloontipText via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify the text in 'balloonTipText' attribute under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon />
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.3 TooltipText

Gets or sets the ToolTip text displayed when the mouse pointer rests on a notification area icon.

Listing 5.1.3.1 Set TooltipText programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.BalloontipText = "Hello World!";
    }
}

Listing 5.1.3.2 Set TooltipText via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify the text in 'tooltipText' attribute under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon />
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.4 TrayIcon

Gets or sets the current icon. It will display an icon for an application in the notification area. 

Listing 5.1.4.1 Set TrayIcon programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.TrayIcon = @"C:\Sample.ico";
    }
}

Listing 5.1.4.2 Set TrayIcon via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify the path to icon file in 'trayIcon' element under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon>C:\Sample.ico</trayIcon>
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.5 ShowInTaskbar

Gets or sets a value indicating whether the main window is displayed in the Windows taskbar. 

Listing 5.1.5.1 Set ShowInTaskbar programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.ShowInTaskbar = true;
    }
}

Listing 5.1.5.2 Set ShowInTaskbar via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify boolean value in 'showInTaskbar' attribute under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon>C:\Sample.ico</trayIcon>
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.6 HideMainWindowAtStartup

Gets or sets a value indicating whether the main window should be displayed or not at the application startup. 

Listing 5.1.6.1 Set ShowInTaskbar programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.HideMainWindowAtStartup = true;
    }
}

Listing 5.1.6.2 Set ShowInTaskbar via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify boolean value in 'hideMainWindowAtStartup' attribute under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon>C:\Sample.ico</trayIcon>
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.7 HideTrayIconWhenMainWindowShown

Gets or sets a value indicating whether the tray icon should be hidden when main window is displayed. 

Listing 5.1.7.1 Set HideTrayIconWhenMainWindowShown programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.HideTrayIconWhenMainWindowShown = true;
    }
}

Listing 5.1.7.2 Set HideTrayIconWhenMainWindowShown via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify boolean value in 'hideTrayIconWhenMainWindowShown' attribute under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon>C:\Sample.ico</trayIcon>
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.8 TurnOnMode

Gets or sets a value indicating when the application is turned on to tray application mode. There are 3 modes to choose from

  1. OnMinimize (Default)
  2. OnClose
  3. OnMinimizeOrClose

Listing 5.1.8.1 Set TurnOnMode programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.TurnOnMode = ChoTrayAppTurnOnMode.OnMinimize;
    }
}

Listing 5.1.8.2 Set TurnOnMode via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify the ChoTrayAppTurnOnMode value in 'turnOnMode' attribute under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon>C:\Sample.ico</trayIcon>
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.9 ContextMenu Settings

Gets or Sets the visibility of each of menu items in the default context menu displayed in the tray icon. Below are menu items can be controled via this settings object

  1. About
  2. Help
  3. Exit
  4. AlwaysOnTop
  5. RunAtSystemsStartup
  6. ShowInTaskbar

Listing 5.1.9.1 Set ContextMenuSettings programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.ContextMenuSettings.DisplayShowInTaskbarMenuItem = false;
    }
}

Listing 5.1.9.2 Set ContextMenuSettings via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify the boolean values to each attributes in 'contextMenuSettings' element under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon>C:\Sample.ico</trayIcon>
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
      <contextMenuSettings displayAlwaysOnTopMenuItem="true" displayRunAtSystemsStartupMenuItem="true" displayShowInTaskbarMenuItem="true" displayAboutMenuItem="true" displayHelpMenuItem="true" displayExitMenuItem="true" />
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

5.1.10 Font Settings

Gets or Sets the fonts propeties to display text instead of icon in the task tray. Using one of the ShowText() overloads to set this text. These are default application wide settings, can be overriable via one of the ShowText() overloads.

Available properties are

  1. FontColor
  2. FontName
  3. FontSize

Listing 5.1.10.1 Set FontSettings programmatically

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
        obj.TrayApplicationBehaviourSettings.ContextMenuSettings.DisplayShowInTaskbarMenuItem = false;
        obj.TrayApplicationBehaviourSettings.FontSettings.FontSize = 9;
    }
}

Listing 5.1.10.2 Set FontSettings via ChoCoreFrx.xml file

Open ChoCoreFrx.xml file, specify the values to each applicable attributes in 'fontSettings' element under 'trayApplicationBehaviourSettings' element.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <globalApplicationSettings applicationId="WindowlessTrayApp.exe" eventLogSourceName="WindowlessTrayApp.exe">
    <behaviourSettings hideWindow="false" bringWindowToTop="false" alwaysOnTop="false" runAtStartup="false" runOnceAtStartup="false" singleInstanceApp="true" activateFirstInstance="false" showEnvironmentSelectionWnd="true" />
    <trayApplicationBehaviourSettings turnOn="false" showInTaskbar="true" hideMainWindowAtStartup="false" tooltipText="" balloonTipText="Hello World!" hideTrayIconWhenMainWindowShown="false" turnOnMode="OnMinimize">
      <trayIcon>C:\Sample.ico</trayIcon>
      <fontSettings fontName="Helvetica" fontSize="8">
        <fontColor />
      </fontSettings>
      <contextMenuSettings displayAlwaysOnTopMenuItem="true" displayRunAtSystemsStartupMenuItem="true" displayShowInTaskbarMenuItem="true" displayAboutMenuItem="true" displayHelpMenuItem="true" displayExitMenuItem="true" />
    </trayApplicationBehaviourSettings>
  </globalApplicationSettings>
</configuration>

6. Advanced Topics

Now that we learned about configuraring tray application via programmatically as well as configuration file. In this section we dive into more advanced approach to customize your tray application programatically, something seldom used.  

6.1 AfterNotifyIconConstructed() Method

When implemented in a derived class, executes after the ChoNotifyIcon object constructed by the framework. In this method, you can manipulate most of the ChoNotifyIcon properties based on your neeeds. Please refer ChoNotidyIcon class help for more information. Besides standard properties exposed via this object, it also provides some additional helper methods to use. 

Listing 6.1.1 AfterNotifyIconContructed() sample

[ChoApplicationHost]
public class ChoAppHost : ChoApplicationHost
{
    protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
    {
        obj.TrayApplicationBehaviourSettings.TurnOn = true;
    }

    public override object MainWindowObject
    {
        get
        {
            return new MainWindow();
        }
    }

    protected override void AfterNotifyIconConstructed(Cinchoo.Core.Windows.Forms.ChoNotifyIcon ni)
    {
        ni.Text = "AfterConstruct";
        ni.ShowText("R");
    }
}

6.2 Running in Console Mode

The applications created using Cinchoo framework can be run as either Console, Windows, Tray or Service applications. Unified interface to switch application from one mode to another. After successful development of tray application, pass /#AM:Console command line argument in order to run your tray application as console mode.

Listing 6.2.1 Run tray application in console mode

>HelloWorldTrayApp /#AM:Console

7. ChoNotifyIcon Class

Specifies a component that creates an icon in the notification area. This class cannot be inherited. Icons in the notification area are shortcuts to processes that are running in the background of a computer, such as a virus protection program or a volume control. These processes do not come with their own user interfaces. The NotifyIcon class provides a way to program in this functionality. The Icon property defines the icon that appears in the notification area. Pop-up menus for an icon are addressed with the ContextMenu property. ChoNotifyIcon provides property notification to all changes.

7.1 Methods

7.1.1 ShowText() Overloads

Showing text instead of icon in the tray.

7.1.2 SetAnimationClip() Overloads

Sets the animation clip that will be displayed in the tray. After setting the clips, you can control the animation by calling StartAnimation and StopAnimation methods.

7.1.3 ShowBalloonTip() Overloads

Displays a balloon tip with the specified title, text, and icon in the taskbar for the specified time period.

7.1.4 StartAnimation() Method

Start showing the animation. This needs to be called after setting the clip using SetAnimationClip() methods.

7.1.5 StopAnimation() Method

Stop animation started with StartAnimation method.

7.2 Properties

7.2.1 BalloonTipText Property

Gets or sets the text to display on the balloon tip associated with the ChoNotifyIcon.

7.2.2 BalloonTipTitle Property

Gets or sets the title of the balloon tip displayed on theChoNotifyIcon.

7.2.3 ContextMenu Property

Gets or sets the shortcut menu associated with the theChoNotifyIcon.

7.2.4 ContextMenu Property

Gets or sets the shortcut menu for the icon.

7.2.5 ContextMenuStrip Property

Gets or sets the shortcut menu associated with the ChoNotifyIcon.

7.2.6 Icon Property

Gets or sets the current icon..

7.2.7 Tag Property

Gets or sets an object that contains data about the ChoNotifyIcon.

7.2.8 Text Property

Gets or sets the ToolTip text displayed when the mouse pointer rests on a  notification area icon.

7.2.9 Visible Property

Gets or sets a value indicating whether the icon is visible in the notification area of the taskbar..

7.3 Events

7.3.1 BalloonTipClicked Event

Occurs when the balloon tip is clicked.

7.3.2 BalloonTipClosed Event

Occurs when the balloon tip is closed by the user.

7.3.3 BalloonTipShown Event

Occurs when the balloon tip is displayed on the screen.

7.3.4 Click Event

Occurs when the user clicks the icon in the notification area.

7.3.5 DoubleClick Event

Occurs when the user double-clicks the icon in the notification area of the taskbar.

7.3.6 MouseClick Event

Occurs when the user clicks a System.Windows.Forms.NotifyIcon with the mouse.

7.3.7 MouseDoubleClick Event

Occurs when the user double-clicks the System.Windows.Forms.NotifyIcon with the mouse.

7.3.8 MouseDown Event

Occurs when the user presses the mouse button while the pointer is over the icon in the notification area of the taskbar.

7.3.9 MouseMove Event

Occurs when the user moves the mouse while the pointer is over the icon in the notification area of the taskbar.

7.3.8 MouseUp Event

Occurs when the user releases the mouse button while the pointer is over the icon in the notification area of the taskbar.

 

Please bookmark this article, more updates will come shortly

License

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

Share

About the Author

Cinchoo

United States United States
No Biography provided

Comments and Discussions

 
QuestionGreat post. Pin
jacobwilliam7-Feb-15 21:03
memberjacobwilliam7-Feb-15 21:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150428.2 | Last Updated 9 Nov 2014
Article Copyright 2014 by Cinchoo
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid