显示气球通知 [英] Show a Balloon notification
问题描述
我正在尝试使用以下代码显示气球通知。我已经验证了它是通过使用断点执行的。它也没有显示错误。
I'm trying to use the below code to show a Balloon notification. I've verified that it's being executed by using breakpoints. It's also showing no errors.
我应该怎么做才能调试它,因为它不会抛出错误并且没有显示气球?
What should I do to debug this since it's not throwing errors and not showing the balloon?
private void showBalloon(string title, string body)
{
NotifyIcon notifyIcon = new NotifyIcon();
notifyIcon.Visible = true;
if (title != null)
{
notifyIcon.BalloonTipTitle = title;
}
if (body != null)
{
notifyIcon.BalloonTipText = body;
}
notifyIcon.ShowBalloonTip(30000);
}
推荐答案
您尚未实际指定图标以显示在任务栏中。在LINQPad中运行代码,只需在调用 ShowBalloonTip
之前添加 notifyIcon.Icon = SystemIcons.Application
获取要显示的提示。另请注意,完成 NotifyIcon
实例后,应调用 Dispose
。
You have not actually specified an icon to display in the task bar. Running your code in LINQPad, by simply adding notifyIcon.Icon = SystemIcons.Application
before the call to ShowBalloonTip
I was able to get the tip to be displayed. Also note that you should call Dispose
when you are done with your NotifyIcon
instance.
这篇关于显示气球通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!