gpt4 book ai didi

Writing text to the system tray instead of an icon and show text of 9 characters in the system tray(将文本写入系统托盘而不是图标,并在系统托盘中显示9个字符的文本)

转载 作者:bug小助手 更新时间:2023-10-25 14:44:48 26 4
gpt4 key购买 nike



I am trying to create a windows forms application where I want to show some text dynamically on the system tray instead of the application icon. I used the below code to create a bit map image from the text which will be used to show in system tray. But the space is not suffiecient to show 8 to 9 characters. How to create the space for 9 characters in system tray and show that ico image created from bitmap in that system tray space.

我正在尝试创建一个Windows窗体应用程序,在该应用程序中,我希望在系统托盘上动态显示一些文本,而不是应用程序图标。我使用下面的代码从文本创建了一个位图图像,它将用于在系统托盘中显示。但空格不足以显示8到9个字符。如何在系统托盘中创建9个字符的空间,并在该系统托盘空间中显示从位图创建的ICO图像。


// Create a Bitmap and draw the text on it
Bitmap bitmap = new Bitmap(16, 16);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.DrawString(newText, new Font("Arial", 8), Brushes.Black, new PointF(0, 0));
}

// Convert the Bitmap to an Icon
Icon customIcon = Icon.FromHandle(bitmap.GetHicon());

// Set the custom Icon as the icon for the NotifyIcon
notifyIcon1.Icon = customIcon;

更多回答

There are a lot of sample code like stackoverflow.com/questions/36379547/…

有很多示例代码,比如Stackoverflow.com/Questions/36379547/…

Does this answer your question? Writing text to the system tray instead of an icon

这回答了你的问题吗?将文本写入系统托盘,而不是图标

优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com