11

Can i know how can i make a popup bubble message in my application coded in C#.

Like example, when i start my application, it'll popup saying "Welcome to UbuntuSE App".

And yea, The popup is not the message box popup, it's the popup in the traymenu.

Something similar to this:

enter image description here

PS, If i'm not wrong, this is called Balloon Tooltips. But how can i use this in my codes.

Lrrr
  • 4,755
  • 5
  • 41
  • 63
PirateOwh
  • 131
  • 1
  • 1
  • 5

7 Answers7

22

If you're using Winforms you have the NotifyIcon class. This object has a ShowBalloonTip method which will show a balloon tip:

var icon = new NotifyIcon();
icon.ShowBalloonTip(1000, "Balloon title", "Balloon text", ToolTipIcon.None)
alexn
  • 57,867
  • 14
  • 111
  • 145
4

you must be looking for the Notify Icon Control

enter image description here
another CodeProject Example

here is a full example in MSDN

Rami Alshareef
  • 7,015
  • 12
  • 47
  • 75
4

You can use the NotifyIcon control that's part of .NET 2.0 System.Windows.Forms.

Check : Using the NotifyIcon control

From the msdn,

NotifyIcon : Specifies a component that creates an icon in the notification area. This class cannot be inherited.

Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164
3

You have to set the property "icon" or it won't pop up

    NotifyIcon ballon = new NotifyIcon();
    ballon.Icon = SystemIcons.Application;//or any icon you like
    ballon.ShowBalloonTip(1000, "Balloon title", "Balloon text", ToolTipIcon.None)
KirstieBallance
  • 1,238
  • 12
  • 26
Al-Hanash Moataz
  • 385
  • 4
  • 14
3

NotifyIcon.BalloonTipIcon

ba__friend
  • 5,783
  • 2
  • 27
  • 20
1
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace ShowToolTip
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btBallonToolTip_Click(object sender, EventArgs e)
        {
            ShowBalloonTip();
            this.Hide();
        }

        private void ShowBalloonTip()
        {
            Container bpcomponents = new Container();
            ContextMenu contextMenu1 = new ContextMenu();

            MenuItem runMenu = new MenuItem();
            runMenu.Index = 1;
            runMenu.Text = "Run...";
            runMenu.Click += new EventHandler(runMenu_Click);

            MenuItem breakMenu = new MenuItem();
            breakMenu.Index = 2;
            breakMenu.Text = "-------------";

            MenuItem exitMenu = new MenuItem();
            exitMenu.Index = 3;
            exitMenu.Text = "E&xit";

            exitMenu.Click += new EventHandler(exitMenu_Click);

            // Initialize contextMenu1
            contextMenu1.MenuItems.AddRange(
                        new System.Windows.Forms.MenuItem[] { runMenu, breakMenu, exitMenu });

            // Initialize menuItem1

            this.ClientSize = new System.Drawing.Size(0, 0);
            this.Text = "Ballon Tootip Example";

            // Create the NotifyIcon.
            NotifyIcon notifyIcon = new NotifyIcon(bpcomponents);

            // The Icon property sets the icon that will appear
            // in the systray for this application.
            string iconPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\setup-icon.ico";
            notifyIcon.Icon = new Icon(iconPath);

            // The ContextMenu property sets the menu that will
            // appear when the systray icon is right clicked.
            notifyIcon.ContextMenu = contextMenu1;

            notifyIcon.Visible = true;

            // The Text property sets the text that will be displayed,
            // in a tooltip, when the mouse hovers over the systray icon.
            notifyIcon.Text = "Morgan Tech Space BallonTip Running...";
            notifyIcon.BalloonTipText = "Morgan Tech Space BallonTip Running...";
            notifyIcon.BalloonTipTitle = "Morgan Tech Space";
            notifyIcon.ShowBalloonTip(1000);
        }

        void exitMenu_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        void runMenu_Click(object sender, EventArgs e)
        {
            MessageBox.Show("BallonTip is Running....");
        }
    }
}
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Kevin M
  • 5,436
  • 4
  • 44
  • 46
1

Thanks for the info! Made something like this and worked!

    private void NotifyBaloon(string text, string tooltip, string title, bool show)
    {
        notifyIconMain.Text = text;
        notifyIconMain.BalloonTipText = tooltip;
        notifyIconMain.BalloonTipTitle = title;
        if (show)
            notifyIconMain.ShowBalloonTip(1000);
    }
Thnks
  • 11
  • 1