GX777, Скрыть форму "при ее запуске":
| Код | private void FormMain_Shown(object sender, EventArgs e) { this.Hide(); }
|
Но зачем скрывать, если можно не показывать:
| Код | static class Program { [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new FormMain()); NotifyIcon ni = new NotifyIcon(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); ni.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); ni.Text = "notifyIcon1"; ni.Visible = true; ni.MouseClick += new MouseEventHandler(ni_MouseClick); Application.Run(); }
static void ni_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) Application.Exit(); else { FormMain f = (sender as NotifyIcon).Tag as FormMain; if (f == null || f.IsDisposed) { (sender as NotifyIcon).Tag = f = new FormMain(); f.Show(); f.Activate(); } } } }
|
Это набросок. Чисто для иллюстрации. |