In somewhere of this page I read that the best way to "override" the minimize method is to use onResize()
event.
I've done it and it works! I've coded that when the form is minimized it turns no visible and put an icon in the windows tray. As yet everything is working fine, but I've also programmed (or tried it at least) that when the icon in windows tray is clicked, the form turns visible again, but it doesn't work and I don't know why.
I've tried to code both events (Click and MouseClick), but the code is the same in both and it still doesn't work, so I must be doing something wrong, but obviusly I don't know what.
Remember that what I want is to code the click event on windows tray icon, not on task bar icon, so maybe that's why it isn't working, maybe is another event.
Here is my code:
private void onResize(object sender, EventArgs e)
{
this.ShowInTaskbar = false;
notifyIcon1.Visible = true;
this.Visible = false;
}
private void notifyIcon_MouseClick(object sender, MouseEventArgs e)
{
this.ShowInTaskbar = true;
this.Visible = true;
}
private void notifyIcon_Click(object sender, EventArgs e)
{
this.ShowInTaskbar = true;
this.Visible = true;
}
Thanks.
EDIT: the problem was that I just assigned the image to the icon on the Form constructor like notifyIcon1.Icon = new Icon("greenCircle.ico");
but I didn't initialize any image on the notifyIcon properties... By initializing the image on notifyIcon properties it worked fine!