Reputation: 7066
I'm creating a windows application. In this application I'm using notifyicon
and minimizing my application to system tray. In my code on button click, I process some thing in background and returns a integer value every 2 seconds. I need to display the Value over the Notifyicon
.
Can anyone help me???
Upvotes: 5
Views: 11365
Reputation: 5691
Try this one. Hopefully this helps you.
http://www.dotnetperls.com/notifyicon
http://www.codeproject.com/Articles/37451/Display-Progress-and-Overlay-Icons-for-Multiple-Vi
And the most you can do some thing like this.
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());
Upvotes: 3
Reputation: 10357
Try NotifyIcon.ShowBalloonTip
method:
Displays a balloon tip with the specified title, text, and icon in the taskbar for the specified time period.
void Form1_DoubleClick(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(20000, "Information", "This is the text",
ToolTipIcon.Info );
}
If you want to change the tray icon, create an icon ondemand and set it to NotifyIcon.Icon
:
to create icon you can use this codes (Updated):
public static Icon GetIcon(string text)
{
Bitmap bitmap = new Bitmap(32, 32);
Icon icon = SmsSender.Properties.Resources.notifficationicon;
System.Drawing.Font drawFont = new System.Drawing.Font("Calibri", 16, FontStyle.Bold);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
graphics.DrawIcon(icon, 0, 0);
graphics.DrawString(text, drawFont, drawBrush, 1, 2);
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
drawFont.Dispose();
drawBrush.Dispose();
graphics.Dispose();
bitmap.Dispose();
return createdIcon;
}
see this same project:
Upvotes: 11