473,406 Members | 2,894 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,406 software developers and data experts.

Closing to tray?

Hello! Newbie C# student here.

How can I make my application close to tray icon instead of closing completely?
If I could change the X button (the one on the top right, I don't know the technical term for it) to not close the application, but do something else, I could probably figure it out.

Thanks on behalf!
/Mossmyr

Nevermind! Found this:
http://stackoverflow.com/questions/1...a-windows-form
Jan 18 '12 #1
1 1634
PsychoCoder
465 Expert Mod 256MB
First check out the NotifyIcon and the FormClosing event, similar to this:

Expand|Select|Wrap|Line Numbers
  1. private void Form1_FormClosing(Object sender, FormClosingEventArgs e)
  2. {
  3.     if (FormWindowState.Minimized == this.WindowState)
  4.     {
  5.         ni.Visible = true;
  6.         ni.ShowBalloonTip(500);
  7.         this.Hide();
  8.     }
  9.     else if (FormWindowState.Normal == this.WindowState)
  10.     {
  11.         ni.Visible = false;
  12.     }
  13. }
Hope that helps :)
Jan 18 '12 #2

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

Similar topics

3
by: Nicolas Poirier | last post by:
I successfully made a system tray application. When I do shut down the computer, how does the computer can instruct my application to shut down? For the moment, if I don't quit my application,...
3
by: Claire | last post by:
Windows refuses to close down if my applications main form is hidden and there's a notify icon in the system tray. If I restore the form, then shutting down Windows succeeds. If I comment out the...
1
by: Manoj Nair | last post by:
Hi, The problem : Have a system tray application.This has a menu item 'Exit'. On click of this a differnt application with a UI which runs in the background should close. The other application...
10
by: One Handed Man [ OHM ] | last post by:
If this is duplicated, I'm sorry because I cant find the original post I made today Anyway . . Now its my turn to ask a question I want to develop an app which will run in the system tray....
8
by: george d lake | last post by:
Hi, I have an app that runs in the system tray. When I exit the app (from a button on a form) the app ends but the icon stays in the tray. Any ideas? here is the code I use to end the app ...
3
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory...
1
by: Zamdrist | last post by:
Trying to get my tray icon application to work as expected. Normally when you close an opened try icon application it minimizes to the tray. I have that part working by interrupting the close even...
4
by: =?Utf-8?B?a3RwbW01?= | last post by:
I've got a basic system tray application running now. The primary focus of this application will be to get data from a remote db, and display it to the user. Iam a newbie in the Windows programming...
3
by: holaboxdotcom | last post by:
Hey I'm pretty new to C# (started few hours ago) but i learn extremly fast, i have previous knowledge of php, javascript and flash. I have made my first simple application the way i want it,...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.