I'm currently writing an application that has a NotifyIcon and I'm trying to figure out a way to overlay text on to it. So for example, if the icon indicates the number of files open, it has the icon plus the number on top of it.
Is there a way to do that? I've seen instances of the NotifyIcon solely being text, SpeedFan for example.
Any suggestions or references would be appreciated.
Add a reference to System.Drawing
. The following code is taken from one of my applications, it applies a 2
on the icon.
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());
My best guess is to generate the icon on the fly. There should be something you can use in System.Drawing. I'm not really familiar with the namespace so I can't give examples. I'm sure others can, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With