473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

110 New Member
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
5 3348
Fuzz13
110 New Member
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 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Top Contributor
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 New Member
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 "SizeChange d" and choose "Form1_Resi zed" 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
4376
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 has been executed on startup or not (from registry key etc.) and minimize itself if it has. An example of a program that does this is Winkey ( http://download.com.com/3000-2344-913626.html?tag=lst-0-1 ). Thank you in advance.
9
6962
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 his users run PC Anywhere from the shell, and minimize it, it minimizes to the system tray. With no task bar, there is no system tray, so there is no way to restore the PC Anywhere window. The shell starts PC Anywhere using ShellExecute. I...
3
1894
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 too elegant to have it in the taskbar. Thanks.
4
4100
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 applications have a 4th one (apart from the square , bar and X ) which contains a dot and once u click it minimizes the application to the tray. TIA
5
2638
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 could use? I'm using Microsoft Visual Basic 2005 Express Edition. Thanks in advance.
2
2640
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 sysem tray, it will just reopen the running instance, not create another instance. Put this Function into a Module in a DLL and call it like If NoLoad(Me) then END in your Form1.Load routine. This function returns TRUE if an instance is...
10
3139
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
2856
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 tray button. I have a Form that pops up when excel loads, and I will add a command button called Minimize that I just want to minimize excel to the system tray.
0
1092
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
17676
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 appears in the task bar. Is there a way to remove the application from the task bar? Here is my current code for minimize. private void Form1_Resize(object sender, System.EventArgs e) { if (FormWindowState.Minimized ==...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.