Display text above notification icon in Windows application

I am creating a windows application. In this application, I use notifyicon and minimizing my application in the system tray. In my code, when I click a button, I process something in the background and return an integer value every 2 seconds. I need to display a value above notifyicon .

Can someone help me ???

+4
source share
2 answers

Try the NotifyIcon.ShowBalloonTip method:

Displays the tip of the ball with the specified title, text, and icon on the taskbar for a specified period of time.

 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 the ondemand icon and set it to NotifyIcon.Icon :

you can use these codes to create the icon (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 the same project:

+9
source

Try it. Hope this helps you.

http://www.dotnetperls.com/notifyicon

http://www.codeproject.com/Articles/37451/Display-Progress-and-Overlay-Icons-for-Multiple-Vi

And most of all you can do something 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()); 
+2
source

Source: https://habr.com/ru/post/1436077/


All Articles