How to Create a Notify Icon in C# without a form
2006-09-16 14:11
489 查看
参考: http://bluehouse.wordpress.com/2006/01/24/how-to-create-a-notify-icon-in-c-without-a-form/
Tested with .NET Framework 2.0 and Windows XP Professional SP2.
我想创建一个带Notify Icon的应用程序,但是不需要Forms。那么如何编写一个没有窗体的NotifyIcon程序哪?我找到了 http://bluehouse.wordpress.com/2006/01/24/how-to-create-a-notify-icon-in-c-without-a-form/ 。稍做修改,形成如下代码:
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5 using System.ComponentModel;
6 using System.Drawing;
7
8 class Portal
9 {
private IContainer container;
private NotifyIcon notifyIcon;
public Portal()
{
Icon icon = new Icon(SystemIcons.Application, 16, 16);
this.container = new Container();
this.notifyIcon = new NotifyIcon(this.container);
this.notifyIcon.Icon = icon;
this.notifyIcon.Visible = true;
}
}
static class Program
{
[STAThread]
static void Main()
{
new Portal();
Application.Run();
}
}
Tested with .NET Framework 2.0 and Windows XP Professional SP2.
我想创建一个带Notify Icon的应用程序,但是不需要Forms。那么如何编写一个没有窗体的NotifyIcon程序哪?我找到了 http://bluehouse.wordpress.com/2006/01/24/how-to-create-a-notify-icon-in-c-without-a-form/ 。稍做修改,形成如下代码:
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5 using System.ComponentModel;
6 using System.Drawing;
7
8 class Portal
9 {
private IContainer container;
private NotifyIcon notifyIcon;
public Portal()
{
Icon icon = new Icon(SystemIcons.Application, 16, 16);
this.container = new Container();
this.notifyIcon = new NotifyIcon(this.container);
this.notifyIcon.Icon = icon;
this.notifyIcon.Visible = true;
}
}
static class Program
{
[STAThread]
static void Main()
{
new Portal();
Application.Run();
}
}
相关文章推荐
- How to get app icon badge numbers in iOS7 without push notifications
- How to create simple and advanced pivot tables in C# and ASP.NET
- How to Create Thumbnail Images in C#
- How to create a PictureMarkerSymbol (Picture Symbol)in ArcGIS server with C#
- How to create your own ListBox in C#
- How to create a DLL library in C and then use it with C#
- How to create (and deploy) a windows service in C# ?
- How to Create Multilingual Webpart in SharePoint 2010 (C# 方式)
- How to create a File-Compare function in Visual C#
- How to create a PictureMarkerSymbol (Picture Symbol)in ArcGIS server with C#
- "HOW TO: Create a Smooth Progress Bar in Visual C# .NET"的学习笔记
- How to make Windows Form app truly Full Screen (and to hide Taskbar) in C#? 转
- How to create Excel file in C#
- How to create a DLL library in C and then use it with C#
- HowTO: Create an Event Log Source in code, without the Permission errors
- How to retrieve AssemblyInfo in C#
- CodeProject - How to develop a screen saver in C#(翻译)
- How To Create a Full Android Phone or Tablet Backup Without Rooting or Unlocking Your Device
- How to create and execute JAR file in Java – Command line Eclipse Netbeans
- How do I convert an enum to a list in C#?