I made this simple little application which goes in the notification area (the little arrow on the taskbar which holds a few applications that run in the background).
I have a button made where I can minimize it using:
this.WindowState = FormWindowState.Minimized;
and I can put the WindowState back to normal mode with:
this.WindowState = FormWindowState.Normal;
This all works fine however when I try to click outside the application to minimize it, instead of pressing the button for it, it doesn't wanna go back to the normal state, even if I use the statement mentioned before.
Is there any setting I can use to toggle this behaviour, or do I need to change something inside the script and if so, what?
I've tried searching through the different settings on both the NotifyIcon and the ContextMenuStrip but couldn't find anything relevant but I might have also just missed it.
I've also tried to search through stackoverflow, but I'm not really sure what to search for, since nothing really popped up when trying to search for almost the same thing as the title on this thread.
Current Code:
private void button1_Click(object sender, EventArgs e)
{
File.WriteAllText("count.txt", count.ToString()); // Ignore this
this.WindowState = FormWindowState.Minimized;
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.WindowState = FormWindowState.Normal;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void showToolStripMenuItem_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
}
Figured out that the issue was not about it minimizing the form, however it was prioritizing the window I was clicking on. To fix this and change it to the top I used
this.TopMost = true
Which worked perfectly.