473,378 Members | 1,438 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,378 software developers and data experts.

Can't Shutdown with System Tray Application Running

hi all

Can't Shutdown with System Tray Application Running in C#.net

Regards
Venu
Nov 16 '05 #1
1 2021
Hi Venu,

I managed that feature once, by cancelling all closing events (user had to select exit from menu). One way to overcome this is to detect the WM_QUERYENDSESSION message from windows

private bool closing = false;

protected override void WndProc(ref Message m)
{
if(m.Msg==0x0011) //WM_QUERYENDSESSION
{
closing = true;
}
base.WndProc(ref m);
}

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if(!closing) // not ready to close yet
{
this.Hide(); // hide the window instead of closing it
e.Cancel = true;
}
}
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Meier | last post by:
Hi list, I am facing the problem that the system shutdown does not close my .net application running in the system tray. After googeling around I implemented this function: protected override...
4
by: David Meier | last post by:
I have an application running in the background, visible only by a notify icon in the system tray. I learned from other posts to catch the WM_QUERYENDSESSION and WM_ENDSESSION messages. Now, when I...
1
by: mikelostcause | last post by:
I'm new to c# and am currently developing a small login/logout app that runs in the system tray. I am trying to get it to access a website during system shutdown, but it doesn't seem to want to. ...
3
by: Erik Greene | last post by:
I have written an application that contains a notifyicon that will not dispose or end when Windows shutsdown. I have seen other posts where people are experiencing the same issue (see post in...
8
by: trialproduct2004 | last post by:
Hi all. I am having application in vb.net. I am having module and one form. From module i am opening form. On main itself i am checking whether another instance of application is running or...
2
by: Steve Lang | last post by:
Hi all, I have a fairly simple VB.Net app in which I capture some data when the user exits the application the "normal" way. However, I still want to capture the same data when the application...
2
by: Sin Jeong-hun | last post by:
I created a windows form application. It has a Threading.Timer and when the timer ticks it does some work and show a popup window. The problem is that while this program is running if the user...
3
by: Kate77 | last post by:
Hello, I have a strange problem, I have application running in the tray bar, for some reason I cant reboot the computer when it is running and i have to close it if i want the computer to do a...
5
by: Lawyno | last post by:
Hi there, we are creating some automated backup solution for some user application (let's say "UserApp" ;)). Now, the backup service is working perfectly. But there's a problem: the backups...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.