How to create rich tooltips and rich balloons in notification area
Asked Answered
C

2

10

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.

Cheerful answered 12/1, 2012 at 14:14 Comment(1)
My good look doesn't tell me that. What's different about your look? Yes, they use large custom icons. That's been supported since Windows XP SP2. Use the Shell_NotifyIcon function to create them.Morganne
D
6

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.

Decarbonate answered 12/1, 2012 at 18:21 Comment(0)
H
0

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:

https://i.sstatic.net/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. :)

Hexad answered 12/1, 2012 at 14:36 Comment(2)
You really don't need to do all of that, nor do you need to use WPF. Support for this is built into Windows.Morganne
Well the windows API is capable... i didntfind a strong enogh yet easier way. What did you have in mind?Hexad

© 2022 - 2024 — McMap. All rights reserved.