【发布时间】:2014-08-22 11:54:34
【问题描述】:
在我的 WinForms 应用程序中,我想在应用启动器图标中显示通知计数。
如何做到这一点?
【问题讨论】:
-
什么是 Windows 桌面操作系统中的应用启动器图标?你是在说捷径吗?
-
不,应用程序运行时底部显示的图标(连同开始按钮)。
标签: winforms count notifications icons app-launcher
在我的 WinForms 应用程序中,我想在应用启动器图标中显示通知计数。
如何做到这一点?
【问题讨论】:
标签: winforms count notifications icons app-launcher
我相信this 是您所要求的,不幸的是它在 WPF 中。 Winforms 没有提供这样做的方法。您需要手动 P/Invoke。
下载Windows 7 API Code Pack - Shell 并使用以下内容。
private void SetTaskBarOverlay()
{
string notificationCount = "3"; //To do: Add this as a parameter
var bmp = new Bitmap(32, 32);
using (Graphics g = Graphics.FromImage(bmp))
{
g.FillEllipse(Brushes.Blue, new Rectangle(Point.Empty, bmp.Size));
g.DrawString(notificationCount, new Font("Sans serif", 25, GraphicsUnit.Point),
Brushes.White, new Rectangle(Point.Empty, bmp.Size));
}
var overlay = Icon.FromHandle(bmp.GetHicon());
TaskbarManager.Instance.SetOverlayIcon(overlay, "");
}
private void RemoveTaskBarOverlay()
{
TaskbarManager.Instance.SetOverlayIcon(null, "");
}
您可以更改绘画代码以达到所需的效果。
【讨论】: