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

Home Posts Topics Members FAQ

How to test windows form is closed by user's clicking on the "x"

I need to test if the form is closing because of user's
clicking on the "x" button, instead of other buttons, such
as my "Exit" button, on my form.

I would like to test this in my form's Closing event
handler, but I don't know how to do this.

Can someone show me how?

Thanks.
Nov 20 '05 #1
7 1415
Cor
Hi Feng,

When I want to know this kind of things and I do not know the solution I do
not look very long.

I set a global (private) bool/switch/status whatever you want and do on my
close-button and the others events something as closeSwitch = true

Than I test in the closing event on that closeSwitch and I know.

Cor
I need to test if the form is closing because of user's
clicking on the "x" button, instead of other buttons, such
as my "Exit" button, on my form.

I would like to test this in my form's Closing event
handler, but I don't know how to do this.

Can someone show me how?

Nov 20 '05 #2
* "feng" <an*******@discussions.microsoft.com> scripsit:
I need to test if the form is closing because of user's
clicking on the "x" button, instead of other buttons, such
as my "Exit" button, on my form.


Determine a Form's UnloadMode
<http://www.fawcette.com/archives/premier/mgznarch/vbpj/2001/11nov01/qa0111/qa0111.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Use the QueryUnload event routine to take whatever action you want
when the user closes the form by clicking the "X" button on the form.

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

every form has this event handler--read the VB help file for the
QueryUnload event.
On Sat, 14 Feb 2004 23:13:49 -0800, "feng"
<an*******@discussions.microsoft.com> wrote:
I need to test if the form is closing because of user's
clicking on the "x" button, instead of other buttons, such
as my "Exit" button, on my form.

I would like to test this in my form's Closing event
handler, but I don't know how to do this.

Can someone show me how?

Thanks.


Nov 20 '05 #4
"James Gray" <ji*****@quik.com> schrieb
Use the QueryUnload event routine to take whatever action you want
when the user closes the form by clicking the "X" button on the form.

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

every form has this event handler--read the VB help file for the
QueryUnload event.


The event does not exist.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
To the OP...

There is a discussion here:
http://www.gotdotnet.com/Community/M....aspx?id=40651

Perhaps that can be of help,
Tom

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eY**************@TK2MSFTNGP12.phx.gbl...
"James Gray" <ji*****@quik.com> schrieb
Use the QueryUnload event routine to take whatever action you want
when the user closes the form by clicking the "X" button on the form.

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

every form has this event handler--read the VB help file for the
QueryUnload event.


The event does not exist.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
Cor
Hi Tom,

Become I crazy, just a switch to test in the closing event and than you know
it.

What do I mis?

Cor

Nov 20 '05 #7
Hi Cor,

I saw your reply the other day and it sounds fine to me. I guess there are
several ways the window could be being told to close however. If you want
to handle things differently a bunch of flags might not be as handy. I
really don't know.

Tom

"Cor" <no*@non.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi Tom,

Become I crazy, just a switch to test in the closing event and than you know it.

What do I mis?

Cor

Nov 20 '05 #8

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

Similar topics

2
by: John Davis | last post by:
I want to know what's the differences between Request.Form("Field Name") and Request.QueryString("Field Name") OR they function exactly the same, which is to return the value of the field?? ...
1
by: David Bradbury | last post by:
Hi On my form, as soon as the user clicks my submit button a message pops up saying "Form processing" as the form submits. This is fine as long as the user only clicks the submit button once....
2
by: Dave | last post by:
These code generates the error: WebRequest request = WebRequest.Create("http://www.yahoo.com"); WebResponse response = request.GetResponse(); Here is the stack trace for the error: ...
3
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their...
0
by: UDBDBA | last post by:
Hi: Currently, MAXFILOP cfg parameter is set to maximum value allowed for AIX 64bit: Max DB files open per application (MAXFILOP) = 1950 Still, we see "Database files closed"...
0
by: jack | last post by:
I have written a fairly simple c# server that uses asynchronous sockets. I have two different clients that connect and send/receive info from the server. Both exihibit this behaviour where...
2
by: Ron | last post by:
I'm trying to check the value of a checkbox and respond accordingly. I had one checkbox working then I changed the name and value and it stopped working. I've checked very carefully to make sure...
10
by: universalbitmapper | last post by:
Hi, I'm trying a simple form.html that call a .html script that begins with: <?php header("This is a test"); ?> When I click on the link, I get blank page.
5
by: Stefano Tonello | last post by:
Hi all, I need to call windows' "open with" dialog from my C# windows form application. After the user selects application, control must return to me (I have to launch directly the process). I...
4
by: Sin Jeong-hun | last post by:
I don't get the message so it's hard to debug that, but some of my clients report that they get "The underlying connection was closed unexpectedly" exception. According to this site (http://...
0
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,...
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
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...
1
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.