RSS Forums RSS
Please support our C# advertiser: Programming Forums
Views: 15451 | Replies: 2
Reply
Join Date: Jun 2005
Posts: 1
Reputation: tenbellys is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tenbellys tenbellys is offline Offline
Newbie Poster

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

  #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:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication2
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.NotifyIcon notifyIcon1;
		private System.ComponentModel.IContainer components;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_Click);
			this.SuspendLayout();
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
			// 
			// notifyIcon1
			// 
			this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
			this.notifyIcon1.Text = "notifyIcon1";
			this.notifyIcon1.Visible = true;
			this.notifyIcon1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDown);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 266);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void notifyIcon1_Click(object sender, EventArgs e)
		{
			if (this.WindowState == FormWindowState.Minimized)
				this.Show();
			this.WindowState = FormWindowState.Normal;
			this.Activate();
			notifyIcon1.Visible=true; //if you want to remove from tray when clicked on
		}
		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.Hide();
			notifyIcon1.Visible=true;
		}

		private void notifyIcon1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
		
		}
	}
}


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

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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2003
Location: Bamberg, Germany
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Rep Power: 6
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.

  #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  
Join Date: Jun 2006
Posts: 1
Reputation: ilovcars is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ilovcars ilovcars is offline Offline
Newbie Poster

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:26 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC