Notifyicon with contextmenu and no form.

Hello, i just downloaded and installed the Visual Studio 2005 Express Edition (C#).

I want to make a small app, where a small notifyicon is the "program", it should poll XML/RSS feeds, and then show up in balloontips.

But i can't find a way to remove the form, and only startup the notifyicon.




Answer this question

Notifyicon with contextmenu and no form.

  • MmeBovary

    just hide the form.

    form.hide();


  • Jonathan Kehayias

    Ok i think are two ways:

    1. Try using a custom windows form I mean create a "Image" then use the image like the form, set its potition under the taskbar 900x850px assuming you have an 1024x768px res screen... then when in the event of your notifyicon have been call then move the form to the visible location in your desktop (like MSN Messenger Notify Popup)
    2. Create a Onload Method/Event there:

      this.Showintaskbar = false;
      this.showicon = false;
      this.hide();
      this.notifyicon.enable = true;
      this.notifyicon.visible = true;
      this.ballontip.show("im here if you need me");
      this.tictacclock.start();

      // now call the function whom made the process
      this.ReadRSSCustomMethod(string something); // obviously call your own function

    Please use the correct syntax, this was an example...



  • Nichole

    this.WindowState = FormWindowState.Minimized;

    this.ShowInTaskbar = false;

    notifyIcon1.Visible = true;

    You can set the notifyIcon1's MouseDoubleClick event to show the form if you want.

    Use e.Cancel = true; under the this.FormClosing event to stop the app from exiting, and just keeping the notifyIcon.



  • MikeJingJing

    Your question has been moved from the Installing and registering Visual Studio Express Editions to the Visual C# Express Edition forum where you should be able get more help.

  • mikael sandberg

    Yes you can. I took the example from NotifyIcon and modified it to run in the Program.cs of a new windows form application. I could then remove the default Form1 that was added.

    using System;
    using
    System.Windows.Forms;
    using
    System.Threading;
    using System.Drawing;

    namespace WindowsApplication9
    {
    static class
    Program
    {
    [
    STAThread
    ]
    static void
    Main()
    {
    Application
    .EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false
    );
    NotifyIcon notifyIcon1 = new NotifyIcon
    ();
    ContextMenu contextMenu1 = new ContextMenu
    ();
    MenuItem menuItem1 = new MenuItem
    ();
    contextMenu1.MenuItems.AddRange(
    new MenuItem
    [] { menuItem1 });
    menuItem1.Index = 0;
    menuItem1.Text =
    "E&xit"
    ;
    menuItem1.Click +=
    new EventHandler
    (menuItem1_Click);
    notifyIcon1.Icon =
    new Icon("app.ico"
    );
    notifyIcon1.Text =
    "Form1 (NotifyIcon example)"
    ;
    notifyIcon1.ContextMenu = contextMenu1;
    notifyIcon1.Visible =
    true
    ;
    Application
    .Run();
    notifyIcon1.Visible =
    false
    ;
    }

    private static void menuItem1_Click(object Sender, EventArgs e)
    {
    Application
    .Exit();
    }
    }
    }



  • Cindy_li

    But I don't want the form.
    I think a saw some code once, which started with the notifyicon only.
    Can't i do that


  • Notifyicon with contextmenu and no form.