943,164 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 2540
  • C# RSS
Jan 17th, 2010
0

How to minimize windows form to system tray properly..??

Expand Post »
I am trying to minimize the form to system tray. I have written a piece of code. But the only problem i am facing is that when i try to restore the window from system tray. Win Form appears in taskbar but has lost focused means it doesnt appear on the screen automatically i have to click on taskbar to restore it....
Here is my code
C# Syntax (Toggle Plain Text)
  1. private void Form1_Resize(object sender, EventArgs e)
  2. {
  3. if (this.WindowState == FormWindowState.Minimized)
  4. {
  5. notifyIcon1.Visible = true;
  6. this.Hide();
  7. }
  8. else if (this.WindowState == FormWindowState.Normal)
  9. {
  10. notifyIcon1.Visible = false;
  11. }
  12. }
  13.  
  14. private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
  15. {
  16. this.Show();
  17. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
j4jawaid is offline Offline
6 posts
since Jan 2010
Jan 17th, 2010
1
Re: How to minimize windows form to system tray properly..??
Would something like this work (if you used Visible = false in your resize method instead of Hide())?
C# Syntax (Toggle Plain Text)
  1. private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
  2. {
  3. if(this.WindowState == FormWindowState.Minimized)
  4. this.WindowState = FormWindowState.Normal;
  5. this.Visible = true;
  6. }
Last edited by jonsca; Jan 17th, 2010 at 9:36 am.
Sponsor
Featured Poster
Reputation Points: 1165
Solved Threads: 578
Quantitative Phrenologist
jonsca is offline Offline
4,271 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Datagrid preview problem
Next Thread in C# Forum Timeline: vs 2008 / C# var words to numbers





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC