3

I'm trying add Taskbar Icon overlay with text to windows7 application icon, I did manage to add small overlay but unable to add the text.

Does any one know how to add dynamic text as Taskbar Icon overlay?

Using: WPF and C#

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Prashant Cholachagudda
  • 13,012
  • 23
  • 97
  • 162

1 Answers1

6

You can only add an Image so you have to create that:

    RectangleF rectF = new RectangleF(0, 0, 40, 40);
    Bitmap bitmap = new Bitmap(40, 40, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
    Graphics g = Graphics.FromImage(bitmap);
    g.FillRectangle(System.Drawing.Brushes.White, 0, 0, 40, 40);
    g.DrawString("5", new Font("Arial", 25), System.Drawing.Brushes.Black, new PointF(0, 0));

    IntPtr hBitmap = bitmap.GetHbitmap();

    ImageSource wpfBitmap =
        Imaging.CreateBitmapSourceFromHBitmap(
            hBitmap, IntPtr.Zero, Int32Rect.Empty,
            BitmapSizeOptions.FromEmptyOptions());

    TaskbarItemInfo.Overlay = wpfBitmap;
Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
ceciliaSHARP
  • 1,000
  • 5
  • 14