4

我目前正在编写一个具有 NotifyIcon 的应用程序,并且正在尝试找出一种将文本覆盖在其上的方法。因此,例如,如果图标表示打开的文件数,则它的顶部有图标和数字。

有没有办法做到这一点?我已经看到 NotifyIcon 的实例仅仅是文本,例如 SpeedFan。

任何建议或参考将不胜感激。

4

3 回答 3

7

添加对System.Drawing. 以下代码取自我的一个应用程序,它2在图标上应用 a。

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());
于 2011-08-03T12:28:59.440 回答
1

我最好的猜测是动态生成图标。System.Drawing 中应该有一些可以使用的东西。我对命名空间不是很熟悉,所以我不能举例。不过,我相信其他人可以。

于 2009-10-15T19:51:54.657 回答
0

Well, I didn't figure out a good way of doing this, but in the end it didn't matter. I ended up using the BalloonTip which allowed me to provide information.

于 2009-10-23T01:05:34.523 回答