I have created a non-form c# program that uses the NotifyIcon class.
The text "(Click to Activate)" shows up when I hover the mouse. So I am getting some events handled.
However, The "Click" event does not fire and the Context menu doesnt show up.
public class CTNotify
{
static NotifyIcon CTicon = new NotifyIcon();
static ContextMenu contextMenu = new ContextMenu();
static void Main()
{
//Add a notify Icon
CTicon.Icon = new Icon("CTicon.ico");
CTicon.Text = "(Click to Activate)";
CTicon.Visible = true;
CTicon.Click += new System.EventHandler(CTicon_Click);
//Create a context menu for the notify icon
contextMenu.MenuItems.Add("E&xit");
//Attach context menu to icon
CTicon.ContextMenu = contextMenu;
while (true) //Infinite Loop
{
Thread.Sleep(300); //wait
}
}
private static void CTicon_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Clicked!");
}
}