Results 1 to 3 of 3

Thread: NotifyIcon without a Form

  1. #1

    Thread Starter
    Addicted Member DJ_Catboy's Avatar
    Join Date
    Jan 2003
    Location
    Suffolk, UK
    Posts
    159

    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

  2. #2
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Dont know if its possible to have just a notify icon, but you can hide your main form like this
    Code:
    sysTrayIcon.Visible = true;
    this.Visible = false;
    I know, just a workaround, but it worked for me.

    HTH, Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  3. #3
    New Member
    Join Date
    Mar 2005
    Posts
    1

    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.
    No te se

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width