作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在编写一个具有 NotifyIcon 的应用程序,并且我正在尝试找出一种在其上叠加文本的方法。因此,例如,如果图标指示打开的文件数,则它会在图标上方加上数字。
有办法吗?我已经看到 NotifyIcon 的实例只是文本,例如 SpeedFan。
如有任何建议或引用,我们将不胜感激。
最佳答案
添加对 System.Drawing
的引用。以下代码取 self 的一个应用程序,它在图标上应用了 2
。
Graphics canvas;
Bitmap iconBitmap = new Bitmap(16, 16);
canvas = Graphics.FromImage(iconBitmap);
canvas.DrawIcon(YourProject.Resources.YourIcon, 0, 0);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
canvas.DrawString(
"2",
new Font("Calibri", 8, FontStyle.Bold),
new SolidBrush(Color.FromArgb(40, 40, 40)),
new RectangleF(0, 3, 16, 13),
format
);
notifyIcon.Icon = Icon.FromHandle(iconBitmap.GetHicon());
关于c# - 有没有办法将文本叠加到 NotifyIcon 上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1574606/
我是一名优秀的程序员,十分优秀!