944,082 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 28078
  • C# RSS
Jun 1st, 2005
0

C#,system tray, wont go from task bar.

Expand Post »
hello people

found this site via google and its helped me a great deal so far but ive hit a snag.

from this topic:
http://www.daniweb.com/techtalkforums/thread19672.html

ive managed to create an app that will sit in the system tray and can be minimised and restroed again but the problem is it wont disepear from the task bar. being a complete begginner at this stuff i have no idea where to look.

i was wondering if anyone can help me heres my code:

C# Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7.  
  8. namespace WindowsApplication2
  9. {
  10. /// <summary>
  11. /// Summary description for Form1.
  12. /// </summary>
  13. public class Form1 : System.Windows.Forms.Form
  14. {
  15. private System.Windows.Forms.NotifyIcon notifyIcon1;
  16. private System.ComponentModel.IContainer components;
  17.  
  18. public Form1()
  19. {
  20. //
  21. // Required for Windows Form Designer support
  22. //
  23. InitializeComponent();
  24. notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_Click);
  25. this.SuspendLayout();
  26. //
  27. // TODO: Add any constructor code after InitializeComponent call
  28. //
  29. }
  30.  
  31. /// <summary>
  32. /// Clean up any resources being used.
  33. /// </summary>
  34. protected override void Dispose( bool disposing )
  35. {
  36. if( disposing )
  37. {
  38. if (components != null)
  39. {
  40. components.Dispose();
  41. }
  42. }
  43. base.Dispose( disposing );
  44. }
  45.  
  46. #region Windows Form Designer generated code
  47. /// <summary>
  48. /// Required method for Designer support - do not modify
  49. /// the contents of this method with the code editor.
  50. /// </summary>
  51. private void InitializeComponent()
  52. {
  53. this.components = new System.ComponentModel.Container();
  54. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
  55. this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
  56. //
  57. // notifyIcon1
  58. //
  59. this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
  60. this.notifyIcon1.Text = "notifyIcon1";
  61. this.notifyIcon1.Visible = true;
  62. this.notifyIcon1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDown);
  63. //
  64. // Form1
  65. //
  66. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  67. this.ClientSize = new System.Drawing.Size(292, 266);
  68. this.Name = "Form1";
  69. this.Text = "Form1";
  70. this.Load += new System.EventHandler(this.Form1_Load);
  71.  
  72. }
  73. #endregion
  74.  
  75. /// <summary>
  76. /// The main entry point for the application.
  77. /// </summary>
  78. [STAThread]
  79. static void Main()
  80. {
  81. Application.Run(new Form1());
  82. }
  83.  
  84. private void notifyIcon1_Click(object sender, EventArgs e)
  85. {
  86. if (this.WindowState == FormWindowState.Minimized)
  87. this.Show();
  88. this.WindowState = FormWindowState.Normal;
  89. this.Activate();
  90. notifyIcon1.Visible=true; //if you want to remove from tray when clicked on
  91. }
  92. private void Form1_Load(object sender, System.EventArgs e)
  93. {
  94. this.Hide();
  95. notifyIcon1.Visible=true;
  96. }
  97.  
  98. private void notifyIcon1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  99. {
  100.  
  101. }
  102. }
  103. }

i added this to the onload procedure, great it works but it just moves the app so its floating above the start menu which is no good to me

C# Syntax (Toggle Plain Text)
  1. this.ShowInTaskbar = false;

anyone have any idea idea what could be up
im sure its pretty simple but i cant see it

many thanks
adam
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tenbellys is offline Offline
1 posts
since Jun 2005
Jun 14th, 2005
0

Re: C#,system tray, wont go from task bar.

You have to set the Visible property to false, or call the this.Hide() method.
Reputation Points: 46
Solved Threads: 2
Junior Poster
Iron_Cross is offline Offline
117 posts
since Jul 2003
Jun 5th, 2006
0

Re: C#,system tray, wont go from task bar.

Try this site
under small problem, you may need to use dispose, not sure
http://www.codeproject.com/csharp/trayiconmenu01.asp
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ilovcars is offline Offline
1 posts
since Jun 2006

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: Blogs About C# or .net
Next Thread in C# Forum Timeline: Embedding a spreadsheet and chart into a windows form





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


Follow us on Twitter


© 2011 DaniWeb® LLC