Jump to content

Recommended Posts

Posted

Hi, I want my user to be able to minimise my application to the system tray, which appears as a Notify Icon with the applications Icon on.

I then want the user to be able to double click the icon to maximise the app again, then immediately after, double click the icon to minimise.

private void ni_DoubleClick(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
Show();
WindowState = FormWindowState.Normal;
}

if (WindowState == FormWindowState.Normal)
{
Hide();
WindowState = FormWindowState.Minimized;
}
}

With this code it performs my operation, but only once, How do you get it to continually loop through this procedure.

Thanks

Tony


Posted

Hmm.. I do see a problem with the logic. I see that if your first if statement is true and executes, the 2nd one will too. Because, if minimized set to normal, if normal (yes.. it was just set) set to minimized. To me, once you minimize it, it will never become normal/restored.

My guess would be to use an else instead of another if statement. Eg.. Might work :)

if (WindowState == FormWindowState.Minimized)
{
Show();
WindowState = FormWindowState.Normal;
}
else
{
Hide();
WindowState = FormWindowState.Minimized;
}

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...