I am trying to minimize the form to system tray. I have written a piece of code. But the only problem i am facing is that when i try to restore the window from system tray. Win Form appears in taskbar but has lost focused means it doesnt appear on the screen automatically i have to click on taskbar to restore it....
Here is my code
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
notifyIcon1.Visible = true;
this.Hide();
}
else if (this.WindowState == FormWindowState.Normal)
{
notifyIcon1.Visible = false;
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
}