472,374 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 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 1370
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://...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.