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

Q: How to differentiate onClose via system shutdown vs via control box?

How can you tell if an onClosing event were raised as a result of the
user clicking on the close control vs a system shutdown?

TIA
Nov 15 '05 #1
3 1401
Couldn´t you just define a variable userClose or something like that
and set it to true if the user presses the close button? In the OnClose event
you then just query the variable and can through this determine if the user
shuts the program down or the system.

The only problem is if you allow the user to press the x in the upper right corner.
At the moment the only thing I could imagine is to analyse the mouse coordinates
and if the mouse is hovering above the x and a click occurs, set the variable to true.

Hope this helps.
Greetings, timtos.

<brewman> wrote in message news:11********************************@4ax.com...
How can you tell if an onClosing event were raised as a result of the
user clicking on the close control vs a system shutdown?

TIA

Nov 15 '05 #2
Take a look at Microsoft.Win32.SystemEvents.SessionEnding event
documentation. You should pay particular attention to the remarks about how
to ensure this event firing before System.Windows.Forms.Form.Closing event.

Hope this helps.

<brewman> wrote in message
news:11********************************@4ax.com...
How can you tell if an onClosing event were raised as a result of the
user clicking on the close control vs a system shutdown?

TIA

Nov 15 '05 #3
On Fri, 29 Aug 2003 16:20:33 +0200, "timtos" <ti****@gmx.de> wrote:
When I mentioned the close button I was referring to the "x" next to
the min and max icons. I probably should have said close control.
Ideally I would like to bind my own handler to the close control, but
I don't know if that is possible.
Couldn´t you just define a variable userClose or something like that
and set it to true if the user presses the close button? In the OnClose event
you then just query the variable and can through this determine if the user
shuts the program down or the system.

The only problem is if you allow the user to press the x in the upper right corner.
At the moment the only thing I could imagine is to analyse the mouse coordinates
and if the mouse is hovering above the x and a click occurs, set the variable to true.

Hope this helps.
Greetings, timtos.

<brewman> wrote in message news:11********************************@4ax.com...
How can you tell if an onClosing event were raised as a result of the
user clicking on the close control vs a system shutdown?

TIA


Nov 15 '05 #4

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

Similar topics

0
by: Matthew Fitzpatrick | last post by:
My application has a settings class that is serialized to save and deserialized to load. I'm having a problem where i catch the WM_QUERYENDSESSION event via WinProc to save my application's...
2
by: amywolfie | last post by:
I have a series of 100 select queries (each represents a separate business rule). Each is run after a rule is tested. OnClose of each query, I need to run a report with only the results of...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
1
by: Maverick | last post by:
in normal Window form programming, there's something like form_unload function. but in asp.net the Page_Unload function is obviously not serving the same purpose. Do you guys know how to get the...
6
by: Luke Matuszewski | last post by:
As in topic... has anyone used it ? I tried to use it but i guess i failed... here is a code: <html> <head> <title></title> <script type="text/javascript"> function closedWin() {...
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...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
4
ADezii
by: ADezii | last post by:
Passive Shutdown is a little known, Jet 4 enabled feature that allows you to prevent Users from connecting to a Database. It is also known as Connection Control. This feature is referred to as...
10
by: kpfunf | last post by:
I have an OnClose function that opens a switchboard (SwitchOpen). This function is placed in numerous objects' (reports and forms) OnClose event, and works great. However, a very annoying...
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
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
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...
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.