473,386 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How do I make my program minimize to the system tray?

110 100+
I'm working on a project that will continually run in the background but I want it to minimize to the system tray so it doesn't take up room on the task bar. I added a notification icon that adds its icon to the system tray and this code that is supposed to hide the form when it is minimized:
Expand|Select|Wrap|Line Numbers
  1. private void Form1_Resize(object sender, System.EventArgs e)
  2.         {
  3.             if (WindowState == FormWindowState.Minimized)
  4.                 Hide();
  5. }
  6.  
But when the program is minimized it just goes to my task bar. I'm not certain that it is actually tied to my forms resize event, my form is named "Form1" but it seems like it might not actually recognize that it is supposed to be tied to it. Any suggestions on how to minimize the program to the system tray and remove it from the task bar while its hidden?
Dec 3 '10 #1

✓ answered by GaryTexmo

Oh, in the designer select your form. There's a little lightning bolt there, click that for the list of events. Find the one for Resize and double click the text entry. It'll create an event handler for you, or you can click from a drop-down to select any existing methods that match the required signature.

Sorry, I thought you already had this since you had the Resize method posted in your original post.

Also, you should still use ShowInTaskbar for this, but it would replace the call to Hide() in what you have right now. By this I mean, when you minimize you set the property to false. When you restore, set it to true.

5 3325
Fuzz13
110 100+
I'm pretty sure its not actually associating itself with my minimize event because when I add the hide() to a button click it hides it from my task bar and puts it in my system tray.
Dec 3 '10 #2
GaryTexmo
1,501 Expert 1GB
What is the value of the ShowInTaskbar property on your form? It should be set to false for this application :)
Dec 3 '10 #3
Fuzz13
110 100+
It is set to true. I want it to be visible on the taskbar if the program window is up for user interaction. When I turn the value to false then minimize the program it just hovers the taskbar in a collapsed window it doesn't minimize to the system tray like it is supposed to.

When you double click a button in the design view it pulls up the click event code. How can I similarly pull up the window resize event code?
Dec 3 '10 #4
GaryTexmo
1,501 Expert 1GB
Oh, in the designer select your form. There's a little lightning bolt there, click that for the list of events. Find the one for Resize and double click the text entry. It'll create an event handler for you, or you can click from a drop-down to select any existing methods that match the required signature.

Sorry, I thought you already had this since you had the Resize method posted in your original post.

Also, you should still use ShowInTaskbar for this, but it would replace the call to Hide() in what you have right now. By this I mean, when you minimize you set the property to false. When you restore, set it to true.
Dec 3 '10 #5
Fuzz13
110 100+
Sorry about the confusion. In the tutorial I read on it they provided the code for the event but for some reason my programs don't recognize it if I don't actually signal the event, if I type for a buttons action to occur it doesn't occur unless I actually click the button to force the code in. Here's what I'm struggling with.

I have a button called "Hide". When I click the hide button my code says:
Expand|Select|Wrap|Line Numbers
  1. Hide();
  2.  
and that's all. When I launch my program it shows up in the system tray and on the task bar, then when I click my "hide" button the form is no longer visible on my task bar or on the screen as a window, but is present in my system tray still. When I then have this code present that is supposed to capture the event if i minimize my form it just minimizes the window and leaves it on my task bar which I can only assume means that my event is not matching the code I have that is supposed to tell it what to do:
Expand|Select|Wrap|Line Numbers
  1. private void Form1_Resize(object sender, EventArgs e)
  2.         {
  3.             if (WindowState == FormWindowState.Minimized)
  4.             {
  5.                 HideTheForm();
  6.                 ShowInTaskbar = false;
  7.             }
  8.         }
  9.  
The solution that got it working was to click that lightening bolt you mentioned then choose "SizeChanged" and choose "Form1_Resized" that got it working correctly. Thank you for helping me figure this out.
Dec 4 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Trey Hunner | last post by:
I am creating an open-source alternative to LAN messengers in VB. Right now I have a system tray icon appear when the program loads and it works fine. I now need get the form to recognize if it...
9
by: none | last post by:
Hello all, I wrote a shell program a few years ago in VB6 that needs to be modified. The problem I have is this: The SysAdmin uses this shell in place of Explorer, so there is no taskbar. When...
3
by: VMI | last post by:
How difficult is it to hide my program in the system tray? It's not something that's required, but it'd look to add it since the program will be writing an ascii file every minute. And it wouldn't...
4
by: steve | last post by:
hi all, i was wondering how is it possible to add an extra box ( i think they are called boxes: upper right corner ...) in a form that will minimize it in the system tray? You know some...
5
by: Casper | last post by:
I'm trying to get my program to run in the system tray. I've looked at dozend of tutorials on the web and on newsgroups but I just dont get it! Has anyone got any links or example code that ...
2
by: Robert S. Liles | last post by:
Following the advice of several members, especially Dragon, I have gotten this routine to work. If you double click on your program's icon to load it, and it is already running minimized into the...
10
by: Crouchie1998 | last post by:
Hello To All You Real Programmers Out There!! There is an application called: "Tray It" Webpage: ---------- http://www.teamcti.com/trayit/trayit.htm Direct Download:
1
by: zakhirn | last post by:
Anyone have code that creates a button that will Minimize Excel to the system tray. I do not need anything complicated like changing the minimize button or the close button to a minimize to...
0
by: mutyalarao | last post by:
Hi, I am trying a simple window program in C#. That application should be in system tray and show the window when the icon in the tray is clicked. How can i do this?
22
by: rottmanj | last post by:
I am working on an app that I need to minimize/close to the system tray. More or less I have the minimize to the system tray working, save caveat. When it is minimized the application still...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.