473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

SystemTray Icon

Hello,

I have a C# service that I would like an icon to show in the system tray
upon startup. I put a NotifyIcon on the form and changed the properties as
follows:

Name: ni
ContextMenu: (none)
Icon: {points to location of icon file}
Size: 32,32
Modifiers: Public
Text: EPA Service
Visible: True

Shouldn't it just show up, now?? Or is there something that I have to do to
get it to show?

Thanks in advance,

Andrew
Nov 15 '05 #1
3 4362
It isn't showing up? It should, try deleting it and adding a new one.
Nov 15 '05 #2
Have this code in the service's main .cs file:
(Replace "icontrans.ico" with your icon, or load from resource (harder)).
HTH
using System;

using System.ServiceProcess;

using System.Windows.Forms;

using System.Drawing;

public class MyService : System.ServiceProcess.ServiceBase

{

private System.Windows.Forms.NotifyIcon TheIcon;

private System.Windows.Forms.ContextMenu TheMenu;

private System.Windows.Forms.MenuItem TheMenuItem;

private System.ComponentModel.IContainer components;
public MyService()

{

this.ServiceName = "MyService";

this.CanStop = true;

this.CanPauseAndContinue = true;

this.AutoLog = true;

}
public static void Main()

{

System.ServiceProcess.ServiceBase.Run(new MyService());

}
protected override void OnStart(string[] args)

{

this.components = new System.ComponentModel.Container();

this.TheMenu = new System.Windows.Forms.ContextMenu();

this.TheMenuItem = new System.Windows.Forms.MenuItem();
this.TheMenu.MenuItems.AddRange(

new System.Windows.Forms.MenuItem[] {this.TheMenuItem});
this.TheMenuItem.Index = 0;

this.TheMenuItem.Text = "E&xit";

this.TheMenuItem.Click += new System.EventHandler(this.TheMenuItem_Click);
this.TheIcon = new System.Windows.Forms.NotifyIcon(this.components);

TheIcon.Icon = new Icon("icontrans.ico");

TheIcon.ContextMenu = this.TheMenu;

TheIcon.Text = "MyService Service";

TheIcon.Visible = true;

}
protected override void Dispose(bool disposing)

{

if(disposing)

if(components != null)

components.Dispose();

base.Dispose(disposing);

}
private void TheMenuItem_Click(object sender, EventArgs e)

{

ServiceController scs = new ServiceController("MyService");

scs.Stop();

}

}

and a standard service installer, this is no different to one without an
icon.



"Andrew Mueller" <am******@instechnet.com> wrote in message
news:eU****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a C# service that I would like an icon to show in the system tray upon startup. I put a NotifyIcon on the form and changed the properties as follows:

Name: ni
ContextMenu: (none)
Icon: {points to location of icon file}
Size: 32,32
Modifiers: Public
Text: EPA Service
Visible: True

Shouldn't it just show up, now?? Or is there something that I have to do to get it to show?

Thanks in advance,

Andrew

Nov 15 '05 #3
OK...

The answer is this:

In the services properties, select 'Allow service to interact with the
desktop.'

Thanks.
"Andrew Mueller" <am******@instechnet.com> wrote in message
news:eU****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a C# service that I would like an icon to show in the system tray upon startup. I put a NotifyIcon on the form and changed the properties as follows:

Name: ni
ContextMenu: (none)
Icon: {points to location of icon file}
Size: 32,32
Modifiers: Public
Text: EPA Service
Visible: True

Shouldn't it just show up, now?? Or is there something that I have to do to get it to show?

Thanks in advance,

Andrew

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LZ7MSQ | last post by:
Hello, How can i get back my ServerIcoon in the systemtray ? SQLServer and SQLAgent services are running, but I can't not connect to the server!
0
by: Sphere | last post by:
If I'd like to read out the tooltip of icq.exe, that is shown in the systemtray. How do I have to do that, please help me.
0
by: Michael Bodek?r | last post by:
Hi, I am making a shell replacement application in VB.NET. Would anyone know where to find samples on how to create your own systemtray in VB.NET? I have already got the code for VB6, but I...
4
by: Sylesh Nair | last post by:
hi , I have a System tray application which configures a Windows Service through it (Both written in C#). I have the service polling to a database table every 30 seconds , the time interval is...
4
by: Terry | last post by:
There are a number of things about using unmanaged resources in Windows Forms programming that is unclear to me. In C++, if you loaded an icon resource using "ExtractIcon()", the resource was...
8
by: Adrian | last post by:
How do I put an icon on a form using code? Thank you.
2
by: Kiran | last post by:
I am able to add my applicatoin to system tray. The problem I am facing here is.... I want add more number of instances (System tray Icons) of a single application to the system tray. At...
5
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
3
by: Nina | last post by:
Hi there, I assigned icon for a window's form using form's Icon property at design time. Now I want to change the icon. I tried to replace the old icon with the new icon using form's Icon...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.