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

Q: closing a form

Hi

I'm soooo sorry but I've had to re-post this message again. I have no idea
what has been happening but for some reason I couldn't seem to be able to
see messages that I'd posted earlier.

My question is this - how can I determine if a user clicked the cross in the
top right of the form to close it.

Thanks in advance (and sorry again for re-posting)

Goeff
Mar 21 '06 #1
9 1507
"G .Net" <no********@email.com> schrieb
Hi

I'm soooo sorry but I've had to re-post this message again. I have
no idea what has been happening but for some reason I couldn't seem
to be able to see messages that I'd posted earlier.

My question is this - how can I determine if a user clicked the
cross in the top right of the form to close it.

Thanks in advance (and sorry again for re-posting)

And what if he closes it from the window menu or by pressing Alt+F4 or by
pressing a Close-Button? Does it make a difference?

Maybe you're looking for the Closing or Closed events.
Armin

Mar 21 '06 #2
Hi Armin

I think that the events Close and Closing occur whatever way the form has
closed e.g. if there is button with DialogResult Ok then it will still
trigger the above. I need to know the form has been closed by clicking the
cross.

Geoff

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"G .Net" <no********@email.com> schrieb
Hi

I'm soooo sorry but I've had to re-post this message again. I have
no idea what has been happening but for some reason I couldn't seem
to be able to see messages that I'd posted earlier.

My question is this - how can I determine if a user clicked the
cross in the top right of the form to close it.

Thanks in advance (and sorry again for re-posting)

And what if he closes it from the window menu or by pressing Alt+F4 or by
pressing a Close-Button? Does it make a difference?

Maybe you're looking for the Closing or Closed events.
Armin

Mar 21 '06 #3

As far as I know, the .Net framework does not recognise a difference
between the different possible ways of closing a form.

It might not even be possible at a low level to distinguish them - say,
each method just sends a WM_CLOSE message.

However, as Armin indicated, if you could give more information about
why knowing whether the form was closed this way is important, perhaps
someone could suggest another way to achieve your desired result.

hth,
Alan.

Mar 21 '06 #4
Hi

Interesting.

I've thought of a way to do it. Basically, I'm going to create a boolean
which will be set to true if some buttons are pressed otherwise it will be
left as false. I can then check the variable in the OnClose event which will
give the functionality I require.

The reason I am trying this is that I want to re-set some global variables
if, for example, a cancel button is pressed.

Geoff

"AlanT" <al*******@users.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...

As far as I know, the .Net framework does not recognise a difference
between the different possible ways of closing a form.

It might not even be possible at a low level to distinguish them - say,
each method just sends a WM_CLOSE message.

However, as Armin indicated, if you could give more information about
why knowing whether the form was closed this way is important, perhaps
someone could suggest another way to achieve your desired result.

hth,
Alan.

Mar 21 '06 #5
"G .Net" <no********@email.com> schrieb
Hi Armin

I think that the events Close and Closing occur whatever way the
form has closed e.g. if there is button with DialogResult Ok then it
will still trigger the above. I need to know the form has been
closed by clicking the cross.

If you're using VB 2005, you could handle the FormClosing event and look at
e.CloseReason.

I still don't know if you want to distinguish between the cross and the
window menu and Alt+F4. If this is all the same and there is only a
difference to the button, then you could evaluate the Dialogresult property,
which is only Dialogresult.Ok if you used the button.
Armin

Mar 21 '06 #6
> As far as I know, the .Net framework does not recognise a difference
between the different possible ways of closing a form.


It may not know the difference between Alt-F4 and closing the form, but it
can offer some assistance. In the FormClosing event, you can check the CloseReason
property of the event arg for some ideas. It will tell you if the reason
is due to MDIParent closing, OS shutdown, etc. It does not distinguish between
form closing by the user selecting the X, Alt-F4, and me.close() in a btnOk.Click
handler however.

Jim Wooley
http://devauthority.com/blogs/jwooley
Mar 21 '06 #7
> I'm soooo sorry but I've had to re-post this message again. I have no
idea what has been happening but for some reason I couldn't seem to be
able to see messages that I'd posted earlier.

My question is this - how can I determine if a user clicked the cross
in the top right of the form to close it.


FWIW, you can browse to the original message thread at http://groups.google.com/group/micro...0e849bc599d7fc

Jim Wooley
http://devauthority.com/blogs/jwooley
Mar 21 '06 #8
Cheers Jim

"Jim Wooley" <ji*************@hotmail.com> wrote in message
news:24*************************@msnews.microsoft. com...
I'm soooo sorry but I've had to re-post this message again. I have no
idea what has been happening but for some reason I couldn't seem to be
able to see messages that I'd posted earlier.

My question is this - how can I determine if a user clicked the cross
in the top right of the form to close it.


FWIW, you can browse to the original message thread at
http://groups.google.com/group/micro...0e849bc599d7fc

Jim Wooley
http://devauthority.com/blogs/jwooley

Mar 22 '06 #9
Thanks everybody for all your help.

Geoff

"Jim Wooley" <ji*************@hotmail.com> wrote in message
news:24*************************@msnews.microsoft. com...
I'm soooo sorry but I've had to re-post this message again. I have no
idea what has been happening but for some reason I couldn't seem to be
able to see messages that I'd posted earlier.

My question is this - how can I determine if a user clicked the cross
in the top right of the form to close it.


FWIW, you can browse to the original message thread at
http://groups.google.com/group/micro...0e849bc599d7fc

Jim Wooley
http://devauthority.com/blogs/jwooley

Mar 22 '06 #10

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

Similar topics

1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
4
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate...
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: 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
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
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,...

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.