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

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 1414
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://...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.