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

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 1
Reputation: tenbellys is an unknown quantity at this point 
Solved Threads: 0
tenbellys tenbellys is offline Offline
Newbie Poster

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

 
0
  #1
Jun 1st, 2005
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:

  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

  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
Reply With Quote Quick reply to this message  
Join Date: Jul 2003
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

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

 
0
  #2
Jun 14th, 2005
You have to set the Visible property to false, or call the this.Hide() method.
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 1
Reputation: ilovcars is an unknown quantity at this point 
Solved Threads: 0
ilovcars ilovcars is offline Offline
Newbie Poster

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

 
0
  #3
Jun 5th, 2006
Try this site
under small problem, you may need to use dispose, not sure
http://www.codeproject.com/csharp/trayiconmenu01.asp
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC