Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // L'icône n'est absolument pas liée à la form NotifyIcon ni = new NotifyIcon(); ni.Click += new EventHandler(ni_Click); ni.Text = "Test"; ni.Icon = new System.Drawing.Icon(@"..."); // On prépare la fenêtre à afficher ou cacher f = new Form1(); f.FormClosing += new FormClosingEventHandler(f_FormClosing); ni.Visible = true; // Le Application.Run() ne prend pas d'argument, // puisqu'il n'y a pas de form principale. Application.Run(); } static Form1 f; static void f_FormClosing(object sender, FormClosingEventArgs e) { // Lorsqu'on clique sur la croix, on cache la fenêtre ((Form1)sender).Hide(); // Mais on ne la ferme pas (ainsi, toutes les données // restent les mêmes) e.Cancel = true; } static void ni_Click(object sender, EventArgs e) { // Lorsqu'on clique sur l'icône, on affiche la form f.Show(); }
Application.Exit();
static void Main(); // Ou static void Main(string[] args);
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());