By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

How to find out if a user is closing the Form or if it coming from within the Application ?

P: n/a
There is a program in VB , in which, there is a

Form_QueryUnload( Cancel as Integer, UnloadMode as Integer)

which would be called when the form is being closed. The UnloadMode is used to find out if the Fomr is being closed by the user - in which case this event is to be cancelled - and if it is coming from within the application, then it would close the application.
In .NET, the equivalent Function is

Form_Closing(ByVal eventSender As System.Object, ByVal eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

in which the 'Cancel' Equivalent in the above VB function exists, but not the 'UnloadMode'. What i wanted to know is, how do i now find out if the Form s being closed by the user, or if it is coming from with in the application ?

Thanks in advance.

Nov 20 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Cor
Hi Bande,

I always had the same problems as you.

Now I use the "MyBase.Closing" event
I have no problems anymore with it,

But I don't know if it is because my knowledge of VB.net is improved or that
it is because I use 2003 and Net 1.1 now, because in past, I was always
strugling with it.

Cor
Nov 20 '05 #2

P: n/a
----- Cor wrote: -----

Hi Bande,

I always had the same problems as you.

Now I use the "MyBase.Closing" event
I have no problems anymore with it,

But I don't know if it is because my knowledge of VB.net is improved or that
it is because I use 2003 and Net 1.1 now, because in past, I was always
strugling with it.

Cor
hi,
Can you please tell me how you used the "MyBase.Closing" Event ?

Bande
Nov 20 '05 #3

P: n/a
* "=?Utf-8?B?QmFuZGU=?=" <an*******@discussions.microsoft.com> scripsit:
Form_Closing(ByVal eventSender As System.Object, ByVal eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

in which the 'Cancel' Equivalent in the above VB function exists, but not the 'UnloadMode'. What i wanted to know is, how do i now find out if the Form s being closed by the user, or if it is coming from with in the application ?


Set a flag before closing the application by code. Then you can check
this flag.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #4

P: n/a
Cor
Hi Bande,

I was searching for the answer, then I saw Herfried wrote it already.
A flag like he calls it, is called by others a switch or a boolean.

Cor
Nov 20 '05 #5

P: n/a
* "Cor" <no*@non.com> scripsit:
I was searching for the answer, then I saw Herfried wrote it already.
A flag like he calls it, is called by others a switch or a boolean.


;-)

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #6

P: n/a
Cor
> > I was searching for the answer, then I saw Herfried wrote it already.
A flag like he calls it, is called by others a switch or a boolean.


;-)

Someone made almost this correction on a message from me too yesterday. And
I was busy writing almost the same message as you did (because I did want
to be sure the Alt F4 was not trappable on an easier way when I saw your
message. So I changed it in this way. Not everybody knows what is the
meaning of a flag, or a switch or a boolean, like a lot of people use.

Cor
Nov 20 '05 #7

P: n/a
Cor
Hi Herried,
I had to clean my glasses. I thought you was sending a question mark. Saw it
was not and thought I deleted the message, wrong button.
Cor
Nov 20 '05 #8

P: n/a
* "Cor" <no*@non.com> scripsit:
Someone made almost this correction on a message from me too yesterday. And
I was busy writing almost the same message as you did (because I did want
to be sure the Alt F4 was not trappable on an easier way when I saw your
message. So I changed it in this way. Not everybody knows what is the
meaning of a flag, or a switch or a boolean, like a lot of people use.


I will include all three words in future posts.

;-)

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #9

P: n/a
* "Cor" <no*@non.com> scripsit:
Hi Herried, ^^^^^^^
I had to clean my glasses. I thought you was sending a question mark. Saw it
was not and thought I deleted the message, wrong button.


No problem...

;-)

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #10

P: n/a
On 2003-10-29, Bande <an*******@discussions.microsoft.com> wrote:
There is a program in VB , in which, there is a

Form_QueryUnload( Cancel as Integer, UnloadMode as Integer)

which would be called when the form is being closed. The UnloadMode is used to find out if the Fomr is being closed by the user - in which case this event is to be cancelled - and if it is coming from within the application, then it would close the application.
In .NET, the equivalent Function is

Form_Closing(ByVal eventSender As System.Object, ByVal eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

in which the 'Cancel' Equivalent in the above VB function exists, but not the 'UnloadMode'. What i wanted to know is, how do i now find out if the Form s being closed by the user, or if it is coming from with in the application ?

Thanks in advance.



Here is another alternative....

http://www.ftponline.com/Archives/pr...111/qa0111.asp

You'll want to scroll down till you see the Question - Determine a
Form's UnloadMode.

HTH
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.