如何在通知区域创建丰富的工具提示和丰富的气球

发布于 2024-12-26 04:22:54 字数 2135 浏览 1 评论 0原文

我一直想知道,每当您致电 ShowBalloonTip 方法href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.notifyicon?redirectedfrom=MSDN&view=netframework-4.8" rel="nofollow noreferrer">NotifyIcon 类,你会得到一个像这样的气球工具提示:

标准气球提示
图1:标准气球工具提示



某些应用程序和 Microsoft 产品能够显示的不仅仅是那些“简单”的气球提示。
以下是一些示例:

Windows Update Tip 图2:Windows更新气球工具提示


驱动程序安装提示
(来源:microsoft.com

图3:硬件驱动安装气球提示


USB 安全删除
图4:硬件删除工具提示(程序:USB安全删除)



仔细观察图 2、3 和 4,您会发现它们不是标准的气球工具提示!

Fig2 具有不同的形状,可能是由于设置 Region 属性所致。它还具有一个比标准图标大得多的自定义图标 工具提示图标

Fig3 使用标准形状(我认为),但它有一个自定义图标,不用说比默认的要大工具提示图标 大小。

Fig4 使用标准 ToolTipIcon 但它有不同的形状。


我的问题是如何创建在 .NET 通知区域中看到的“丰富”气球工具提示?我可以处理 WinAPI 并且它可以产生必要的输出。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清君侧 2025-01-02 04:22:54

您必须使用 Win32 函数 Shell_NotifyIcon。您可以设置 NOTIFYICONDATA 结构到 NIIF_USER 以便为气球工具提示使用自定义图标。

在 Windows XP Service Pack 2 及更高版本上,您可以使用 hIcon 成员来指定自定义图标。

在 Windows Vista 及更高版本中,NOTIFYICONDATA 结构包含附加成员 hBalloonIcon。如果您已将 cbSize 成员设置为扩展 NOTIFYICONDATA 结构的正确大小,则可以使用此成员指定自定义图标。

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.

書生途 2025-01-02 04:22:54

看看这个:

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

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

其他选项是制作您自己的通知表单气球,
然后您将收到带有花朵背景和粉红色边框的通知:)
顺便说一句:它也可以有一些功能。

如本例所示:

https://i.sstatic.net/QtA0Y.jpg
<<图像示例

根据您的喜好创建一个表单,区域,控件等:)
代码如下:

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();
    }

顺便说一句,它们看起来都有点相同,但图标大小不同,
第一个可以向右对齐,而其他所有都向左对齐......
细微的色调变化等:)

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. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文