Skip to content

System Tray

ozzy

Asked Jul 25, 2007, 5:58 AM EDT3 answers
Share
LinkedInX
Hi,
I used the code in this http://www.developer.com/net/csharp/article.php/3336751 link. It works but when I open abother form on my main form the number of icons appearing increase. In the program the user needs to open those forms and that becomes messy since the user sees more than 10 icons. How can I prevent those extra icons from appearing when another form is opened on the main form.

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    I'm pretty new to C# so im not sure, but you could probably make a global var to set to true when yoru first form opens. Then in your initializeComponent method you can do an if statement to check if your var is true... if it isnt, create the icon.. if it is... skip that bit :)

    0
  • 0
    I have not worked with C# very much yet either but my mentor has done this very thing. He set a global variable and simply checked the value of this variable, or flag, and controled the icon creation from there.
    0
  • 0

    I tried to use a global variable to control these two functions that I created but I realized that none of these functions create the icon, because the first one is used to hide the program from the taskbar and the second is used to show the program when the icon is clicked. But I don't know what is it that creates that icon therefore I can't control that process. Anyone know what to do?

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

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

    0