Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How To Avoid Bug When I'm Trying To Minimize My Main Form To Tray On Startup?

winforms c# hide tray icon bug

  • Please log in to reply
1 reply to this topic

#1 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 12 July 2012 - 09:04 PM

For my task I am using this code:


// notifyIcon1 put on main form
public Form1()
{
InitializeComponent();

notifyIcon1.Visible = false;
this.notifyIcon1.MouseDoubleClick += new MouseEventHandler(notifyIcon1_MouseDoubleClick);
this.Resize += new System.EventHandler(this.Form1_Resize);
this.Load += new EventHandler(Form1_Load);
}

void Form1_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}



private void Form1_Resize(object sender, EventArgs e)
{

if (WindowState == FormWindowState.Minimized)
{
Hide();
notifyIcon1.Visible = true;

}
}

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
notifyIcon1.Visible = false;
WindowState = FormWindowState.Normal;


}

Well, all seems good, except 1 very bad bug, I have always see a piece of form above the Winodws 7 Start button?

Look at this:

Attached Thumbnails

  • iconForum.png

  • 0

#2 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 12 July 2012 - 09:33 PM

UNSOLVED:

protected override void OnActivated(EventArgs e)
{
this.Hide();
}

I was fast, this is not the solution, 'caz when I click to the trayIcon it's hide my form absolutely.
  • 0





Also tagged with one or more of these keywords: winforms, c#, hide, tray, icon, bug

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download