NotifyIcon without a Form
Hi,
I would like to write an app that is just a NotifyIcon - without a main form. I have tried to call "Hide()" methods of my main form but it doesn't hide! I have also tried writing a standard app without the Form (just code) but I can't get hold of the NotifyIcon as it seems to be wrapped to a form in the framework.
Does anybody know how to do this or have an example of how I may do this?
Many thanks in advance,
DJ
Re: NotifyIcon without a Form
You can create a class like this
Code:
class CNotify
{
System.ComponentModel.Container componentes;
System.Windows.Forms.NotifyIcon ni;
System.Drawing.Icon Icono;
public CNotify()
{
Inicializa();
}
private void Inicializa()
{
Icono= new Icon(GetType(), "post1_1.ico");
componentes= new System.ComponentModel.Container();
ni= new NotifyIcon(componentes);
ni.Text= "Test Notify Icon";
ni.Icon= Icono;
ni.Visible= true;
ni.Click+=new EventHandler(ni_Click);
}
private void ni_Click(object sender, EventArgs e)
{
MessageBox.Show("Click in NotifyIcon");
}
}
and in the start point of the application write this.
Code:
[STAThread]
static void Main()
{
CNotify test;
test= new CNotify();
Application.Run();
}
if you want to end the application just send exit.
Disculpen si tengo un error en mi ingles, trato de escribir lo mejor que puedo.