Creating a Popup Balloon like Windows Messenger or AVG

Malfist picture Malfist · Jan 5, 2009 · Viewed 51k times · Source

How can I create a Popup balloon like you would see from Windows Messenger or AVG or Norton or whomever?

I want it to show the information, and then slide away after a few seconds.

Edit: It needs to be blocking like Form.ShowDialog() because the program exits after displaying the notification

Answer

BFree picture BFree · Jan 5, 2009

You can use the notifyIcon control that's part of .NET 2.0 System.Windows.Forms. That allows you to place an icon for your application in the System Tray. Then, you can call the ShowBalloonTip(int timeOut) method on that. Be sure however to first set the text, and icon properties on the notifyIcon for it to work. Small code sample:

private void button1_Click(object sender, EventArgs e)
        {
            this.notifyIcon1.BalloonTipText = "Whatever";
            this.notifyIcon1.BalloonTipTitle = "Title";
            this.notifyIcon1.Icon = new Icon("icon.ico");
            this.notifyIcon1.Visible = true;
            this.notifyIcon1.ShowBalloonTip(3);
        }

EDIT: Ok, so notifyIcon won't work for you. My second suggestion would then be to create your own control for this. Actually, I would use a form. A simple form, with no borders, and no control box and just have a timer running so you can set the Opacity for fade in/out. Then, you can easily get the bottom right of the screen using the Rectangle Screen.PrimaryScreen.WorkingArea. Then just show your form at that position.