Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification bubbles from nothing in C#

Tags:

c#

in a C# application that has no graphics at all, and does a bunch of network operations, I need to be able to show notification bubbles (on top of everything, for a few seconds) near the icon tray on certain events.

I've been looking at this : http://www.codeproject.com/KB/miscctrl/taskbarnotifier.aspx

But with no success. The problem with it is that the windows designed there won't show on asynchroneous events. It seems that I need a main form first on which I add delegates for it to work, which I have no need for.

All options I've seen so far require me to have a form in my application, but that won't happen. Is it impossible then to have these bubbles ? Any ideas ? There must be a way to add an icon in the tray popping messages inconditionally and without GUI right ?

like image 316
BuZz Avatar asked Nov 23 '11 09:11

BuZz


2 Answers

Taken from Systray icon for Console application and Creating balloon tooltip in C#

Add a reference to both System.Windows.Forms and System.Drawing.

Update:

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

private void Form1_Load(object sender, EventArgs e)
{
    var item = new NotifyIcon(this.components);
    item.Visible = true;
    item.Icon = System.Drawing.SystemIcons.Information;
    item.ShowBalloonTip(3000, "Balloon title", "Balloon text", ToolTipIcon.Info);
}

Also it can be that popups are disabled in registry.

like image 123
Vitaliy Avatar answered Sep 23 '22 07:09

Vitaliy


Look at the NotifyIcon class, it allows you to put icons into the notification area as well as doing balloon notifications which is what you're after.

like image 40
Kevin Holditch Avatar answered Sep 22 '22 07:09

Kevin Holditch