Home All Groups Group Topic Archive Search About
Author
21 Mar 2006 11:45 AM
G .Net
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

Author
21 Mar 2006 11:59 AM
Armin Zingler
"G .Net" <nodamnspam@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
Author
21 Mar 2006 1:15 PM
G .Net
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

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:%23zkiI8NTGHA.5924@TK2MSFTNGP09.phx.gbl...
> "G .Net" <nodamnspam@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
Author
21 Mar 2006 2:48 PM
AlanT
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.
Author
21 Mar 2006 3:00 PM
G .Net
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

Show quoteHide quote
"AlanT" <alanto***@users.com> wrote in message
news:1142952524.460688.84490@u72g2000cwu.googlegroups.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.
>
Author
21 Mar 2006 3:57 PM
Jim Wooley
> 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
Author
21 Mar 2006 3:08 PM
Armin Zingler
"G .Net" <nodamnspam@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
Author
21 Mar 2006 6:22 PM
Jim Wooley
> 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/microsoft.public.dotnet.languages.vb/browse_frm/thread/c1bb8c32c77d8ea1/ba0e849bc599d7fc?q=Q%3Aclosing+a+form&rnum=1#ba0e849bc599d7fc

Jim Wooley
http://devauthority.com/blogs/jwooley
Author
22 Mar 2006 9:17 AM
G .Net
Cheers Jim

Show quoteHide quote
"Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
news:24f81e8e47648c81b01962a286a@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/microsoft.public.dotnet.languages.vb/browse_frm/thread/c1bb8c32c77d8ea1/ba0e849bc599d7fc?q=Q%3Aclosing+a+form&rnum=1#ba0e849bc599d7fc
>
> Jim Wooley
> http://devauthority.com/blogs/jwooley
>
>
Author
22 Mar 2006 9:18 AM
G .Net
Thanks everybody for all your help.

Geoff

Show quoteHide quote
"Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
news:24f81e8e47648c81b01962a286a@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/microsoft.public.dotnet.languages.vb/browse_frm/thread/c1bb8c32c77d8ea1/ba0e849bc599d7fc?q=Q%3Aclosing+a+form&rnum=1#ba0e849bc599d7fc
>
> Jim Wooley
> http://devauthority.com/blogs/jwooley
>
>