Frage

I've been wondering, whenever you call the ShowBalloonTip method of the NotifyIcon class, you get a balloon tooltip like this:

Standard Baloon Tip
Fig1: Standard Balloon Tooltip



Some applications and Microsoft products are able to display more than those 'simple' balloon tips.
Here are some samples:

Windows Update Tip Fig2: Windows Update Balloon Tooltip


Driver Installation Tip
(source: microsoft.com)

Fig3: Hardware Driver Installation Balloon Tooltip


USB Safely Remove
Fig4: Hardware Removal Tooltip (Program: USB Safely Remove)



A good look at Figures 2, 3, and 4 reveals they aren't standard balloon tooltips!

Fig2 has a different shape, possibly from setting the Region property. It also has a custom icon which is much bigger than the standard ToolTipIcon.

Fig3 uses the standard shape (I think) but it has a custom icon which needless to say is larger than the default ToolTipIcon size.

Fig4 uses a standard ToolTipIcon but it has a different shape.


My question is how does one create any of the 'rich' balloon tooltips that are seen in the notification area in .NET? I can handle WinAPI as well as it can produce the necessary output.

War es hilfreich?

Lösung

You have to use the Win32 Function Shell_NotifyIcon. You can set the dwInfoFlags member of the NOTIFYICONDATA structure to NIIF_USER in order to use a custom icon for the balloon tooltip.

On Windows XP Service Pack 2 and later you can use the hIcon member to specify a custom icon.

On Windows Vista and later the NOTIFYICONDATA structure contains the addiional member hBalloonIcon. You can use this member to specify a custom icon if you have set the cbSize member to the correct size of the extended NOTIFYICONDATA structure.

Andere Tipps

Check this out:

http://www.codeproject.com/KB/WPF/WPF_TaskbarNotifier.aspx

or

www.codeproject.com/KB/WPF/wpf_notifyicon.aspx

Other option is to Make your own notification form balloon, then you will have notification with flowers background and pink borders :) BTW: that can have some functionality in it too.

As in this example:

http://i.stack.imgur.com/QtA0Y.jpg << Image Example

Create a form as you like, Region, Controls, Etc :) and code something like:

void notifyIcon_MouseMove(object sender, MouseEventArgs e)
    {
        if (!this.Visible)
        {
            ShowPopup();
        }
    }

    Timer t = new Timer();
    private void ShowPopup()
    {
        Rectangle rect = Screen.GetWorkingArea(new Point(Screen.PrimaryScreen.Bounds.Right, Screen.PrimaryScreen.Bounds.Bottom));
        this.Top = rect.Bottom - this.Height;
        this.Left = rect.Right - this.Width;
        this.Visible = true;

        t.Interval = 4000;
        t.Tick += new EventHandler(t_Tick);
        t.Start();
    }

    void t_Tick(object sender, EventArgs e)
    {
        t.Stop();
        Visible = false;
    }

    private void Form1_Click(object sender, EventArgs e)
    {
        this.Visible = false;
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        notifyIcon.Visible = false;
        notifyIcon.Dispose();
    }

BTW they all look kinda same, with different Icon size, and the First one could fit to the right, while all other are aligned to left... minor shade changes Etc. :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top