如何在C#中创建Nofity图标 [英] How Make Nofity icon in C#
本文介绍了如何在C#中创建Nofity图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建一个在通知区域中有图标的程序?
我想在C#中执行此操作。
谢谢!
How can I create a program that will have an icon in the notification area?
I would like to do this in C#.
Thank you!
推荐答案
NotifyIcon仅适用于WinForms - 因为您以前的问题大多与网络有关,我想我最好提一下......
创建一个WinForms应用程序,并通过从ToolBox拖动将NotifyIcon实例添加到其中。将图标添加到NotifyIcon实例。
处理Form.Load事件:
NotifyIcon is only applicable to WinForms - since your previous questions have mostly been web related, I thought I'd better mention that...
Create a WinForms application, and add a NotifyIcon instance onto it by dragging from the ToolBox. Add an icon to the NotifyIcon instance.
Handle the Form.Load event:
private void frmNotifyArea_Load(object sender, EventArgs e)
{
myNotifyIcon.BalloonTipText = "Inside the PopUp";
myNotifyIcon.BalloonTipTitle = "Popup Title";
myNotifyIcon.ShowBalloonTip(1000);
WindowState = FormWindowState.Minimized;
ShowInTaskbar = false;
}
和Resize事件:
And the Resize event:
private void frmNotifyArea_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
Hide();
}
}
最后是NotifyIcon.MouseDoubleClick事件:
And finally the NotifyIcon.MouseDoubleClick event:
private void myNotifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
WindowState = FormWindowState.Normal;
Show();
}
使用Windows窗体中的NotifyIcon控件,您可以在其中添加自己的图标并将C#代码挂钩到它。试试 MSDN-NotifyIcon Class [< a href =http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon(v=vs.110).aspx\"target =_ blanktitle =New Window> ^ ]
NotifyIcon类提供了一种在此功能中编程的方法。 Icon属性定义通知区域中显示的图标。图标的弹出菜单使用ContextMenu属性进行寻址。
With the NotifyIcon control in Windows Forms, you can add an icon of your own there and hook C# code up to it. Try MSDN-NotifyIcon Class[^]
The NotifyIcon class provides a way to program in this functionality. The Icon property defines the icon that appears in the notification area. Pop-up menus for an icon are addressed with the ContextMenu property.
这篇关于如何在C#中创建Nofity图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文