代码之家  ›  专栏  ›  技术社区  ›  Prashant Cholachagudda

如何添加动态文本作为任务栏图标覆盖?

  •  2
  • Prashant Cholachagudda  · 技术社区  · 16 年前

    我正在尝试将带有文本的任务栏图标覆盖添加到Windows7应用程序图标,我确实添加了小的覆盖,但无法添加文本。

    有人知道如何添加动态文本作为任务栏图标覆盖吗?

    使用:WPF和C#

    1 回复  |  直到 15 年前
        1
  •  5
  •   Dave Clemmer manu    15 年前

    您只能添加 Image 所以你必须创造:

        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;