473,491 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to run application from system tray

1 New Member
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, however i'm having trouble with the system tray icon, i can show/hide the main window using the icon with a context menu etc.

However what i would like to do it to make the icon go to the system tray when i press the red cross in the top right corner rather than completly closing the application, and if someone wishes to close the application they right click the system tray icon and press exit (which i have already setup)

I asked a friend/coworker for some advice but he was busy, he did however say it had something to do with do with catching the SW_QUERYCLOSE event somewhere, but i've had no luck searching for that.

Any help is apreciated and thanks in advance for your time,
Marc
Mar 24 '08 #1
3 1707
gpraghuram
1,275 Recognized Expert Top Contributor
I think this should be part of .NET forum

Raghuram
Mar 24 '08 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
I ma moving this to the .NET forum.
Mar 24 '08 #3
Plater
7,872 Recognized Expert Expert
Well there'a couple of different ways to do this.

Approach One:
You make an empty form and add the sys icon (NotifyIcon) to THAT form. Then set THAT form as the main start up form.
The only job of this form is to be invisible (visible=false) and to launch (keep a reference to) the form you actually want to show/hide. The functionality of the systray icon is changed to show/hide the form you just launched (instead of like this.visible=false, it would be myActualForm.Visible=false, etc)


Approach Two:
On the form you show/hide, you would attach an event handler to the Closing event for the form. There you would take action depending on what the type is (you would want to make sure the OS can close the program, only want to deal with the user tries to close).
You would also want to implent some logic (a simple boolean value perhaps?) to make sure your menu-click item is allowed to close the application as well.
Mar 24 '08 #4

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

Similar topics

1
3695
by: Greg Merideth | last post by:
Is there a way via c# to hook a system tray application into the windows keyboard que globally so that when the application is running and you press, say, control-alt-shift-f11 the system tray app...
0
1410
by: Vinay Agarwal | last post by:
Hello, I am writing an application that wants to monitor another application's state (on the same computer). This other application is a commercial application and I do not have access to its...
3
2033
by: dencdr | last post by:
Hi, I have an application VB.NET (using Form Win32) with no icon in TaskBar. When a FORM of this application is visible I see this application in the list of "Alt+Tab" choice. How do for...
4
3928
by: Curious Coder | last post by:
I have been tasked with a project that I do not think can be accomplished. Our company has an application that runs as an unmanaged ActiveX control on user desktops. It is designed to work with...
1
3247
by: Geraldine Hobley | last post by:
Hello, I have an icon in my system tray and I wish to call various functions from withing the tray which involve the application been maximized. The following event is on the system tray icon ...
10
3113
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:
11
1957
by: Jay | last post by:
Hey There, I have a system tray application that is running, and it needs to communicate with a Windows Service that I wrote. My problem is that if a user switches to another desktop, I need the...
4
6115
by: Octavius Khan | last post by:
I have an application that runs in the system tray and I use global hotkeys to perform functions. When certain hotkeys are pressed, my system tray application may display a message box and...
1
5612
by: =?Utf-8?B?RW5naW5lZXJpaw==?= | last post by:
I have an application which uses a notification icon in the system tray. When the application is closed the notification icon remains in the system tray until I hover over it with the mouse. How...
0
6978
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
7154
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
7190
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...
0
7360
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...
0
5451
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,...
1
4881
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...
0
4578
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...
0
3086
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...
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.