J'ai créé un programme non sous forme C# qui utilise la classe NotifyIcon.WinForms Taskbar Icon - Cliquez sur l'événement non mise à feu
Le texte "(Cliquez pour activer)" apparaît lorsque je passe la souris. Donc, je reçois des événements gérés.
Cependant, l'événement "Click" ne se déclenche pas et le menu contextuel n'apparaît pas.
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!");
}
}