You are running into a problem many people have (and MSDN has had endless complaints about) with multiple copies of the same TaskBar Notify Icon showing up in the Notification area of the TaskBar, sometimes mysteriously vanishing to leave one in place as you mouse over them, but the "root" of the problem is, most often, that people don't realize what TaskBar Notification area Icons are meant to be used for.
TaskBar Notification area Icons are most often used for always-on windows applications that, in general, do not present a user-interface; they are typically
not used to trigger the showing of a minimized Form Window.
As I am sure you are aware of, a TaskBar Notification Icon can present a context-menu, balloon Tooltip, etc.
Triggering the "showing" of a Form Window that has been minimized is
meant to be done by having the Form's 'ShowInTaskBar set to 'true, and having the user click in the main.
So, that's what the conventions for Windows Desktop Applications intend for us to do, and, now that's on the table, let's violate the conventions:
The only somewhat reliable technique I have found (and I have not tested it outside .NET FrameWork 4.5) for presenting a TaskBar Notification area Icon when a Form is Minimized, and then restoring the Form to WindowState Normal when the Icon is clicked is done like this:
private const string iconFilePath = @"C:\?\?\?\SomeIcon.ico";
private void notifyIcon1_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
}
private void Form3_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
notifyIcon1.Icon = Icon.ExtractAssociatedIcon(iconFilePath);
notifyIcon1.Visible = true;
}
else
{
notifyIcon1.Icon = null;
}
}
It's possible this could be "evil code," and I suggest you think carefully about using it :)
More seriously, if you are having multiple Forms displayed, and there's always one "main Form" visible, and you don't want the "secondary" Forms to show up in the TaskBar: why not have a menu on the main Form, that lets you open any hidden/minimized secondary Forms ?