Um ein Programm lediglich als Symbol im Infobereich (Symbole in der Taskleiste) zu starten und zu steuern (z.B. beenden, Info anzeigen) muss lediglich dieser Code in die Program Klasse eingefügt werden.

using System;
using System.Windows.Forms; // NotifyIcon
using System.Drawing; // Icon

namespace OssiSoft {

public class OSNotifyIconMinimum
{
public OSNotifyIconMinimum()
{
}

public static NotifyIcon aAppIcon = new NotifyIcon();
public static ContextMenu aSysTrayMenu = new ContextMenu();
public static MenuItem aDisplayInfo = new MenuItem(„Info über…“);
public static MenuItem aExitApp = new MenuItem(„Beenden“);

static void Main()
{
Icon aIcon = new Icon(@“NOTES.ICO“);
aAppIcon.Icon = aIcon;
aExitApp.Click += new System.EventHandler(ExitApp_Click);
aSysTrayMenu.MenuItems.Add(aDisplayInfo);
aDisplayInfo.Click += new System.EventHandler(DisplayInfo_Click);
aSysTrayMenu.MenuItems.Add(aExitApp);
aAppIcon.ContextMenu = aSysTrayMenu;
aAppIcon.Text = „dot.net-Magazin“;
aAppIcon.Visible = true;
Application.Run();
}

private static void DisplayInfo_Click(object sender, System.EventArgs e)
{
MessageBox.Show(„NotifyIcon ohne Formular“, „Test“,
MessageBoxButtons.OK);
}

private static void ExitApp_Click(object sender, System.EventArgs e)
{
aAppIcon.Dispose();
Application.Exit();
}
}
}

Leave a Reply