Dans la méthode Main, au lieu de
Application.Run(new Form1());
, mets juste .
Comme ça tu n'affiches pas la form au démarrage, tu ne l'affiches que lors du clic sur l'icone
Tu pourrais faire quelque chose comme ça:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| class Program
{
static Form1 _mainForm;
[STAThread]
static void Main(string[] args)
{
_mainForm = new Form1();
NotifyIcon notifyIcon = new NotifyIcon();
notifyIcon.Icon = ...
notifyIcon.Text = ...
notifyIcon.Click += notifyIcon_Click;
notifyIcon.Visible = true;
Application.EnableVisualStyles();
Application.Run();
}
static void notifyIcon_Click(object sender, EventArgs e)
{
_mainForm.Show();
}
} |
Partager