Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to minimize a C# WinForms app to system tray. I've tried this:

Having the application minimize to the system tray when button is clicked?. The first time I minimize it, it's nowhere to be found on the screen - taskbar/above taskbar/tray.

If i hit alt tab, I can see my app there; if I alt tab into it and minimize it again, it shows up above the taskbar:

minimize

What am I doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
249 views
Welcome To Ask or Share your Answers For Others

1 Answer

What about the option of hiding the form when minimized then showing once you click on the tray icon?

In the form resize event, do the check there and hide the form

   private void Form_Resize(object sender, EventArgs e)
    {
        if (WindowState == FormWindowState.Minimized)
        {
            this.Hide();
        }
    }

Then when clicking on the taskbar icon just restore it.

    private void notifyIcon_Click(object sender, EventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...