Kri*_*ota 4 c# windows notifyicon winforms windows-applications
我正在创建一个Windows应用程序.在这个应用程序中,我正在使用notifyicon
并最小化我的应用程序到系统托盘.在我点击按钮的代码中,我在后台处理一些事情并每2秒返回一个整数值.我需要显示价值Notifyicon
.
谁能帮我???
尝试NotifyIcon.ShowBalloonTip
方法:
在指定的时间段内在任务栏中显示带有指定标题,文本和图标的气球提示.
void Form1_DoubleClick(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(20000, "Information", "This is the text",
ToolTipIcon.Info );
}
Run Code Online (Sandbox Code Playgroud)
如果要更改托盘图标,请在需要时创建图标并将其设置为NotifyIcon.Icon
:
要创建图标,您可以使用此代码(更新):
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;
}
Run Code Online (Sandbox Code Playgroud)
看到同样的项目:
归档时间: |
|
查看次数: |
9339 次 |
最近记录: |