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

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

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
10 1643
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
----- 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
* "=?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
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
* "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
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
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
* "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
* "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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sagaert Johan | last post by:
Hi If i have a form application that creates a thread, is there a way to detect from within that thread if i have closed the form ? Now i use the forms closing event to end the thread i...
1
by: Deep Silent Ocean | last post by:
Hi All I am developing one Portfolio Management application where there is single database shared by all the traders. I have developed web-based application for this. I want to make this...
5
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
5
by: Oenone | last post by:
I have a VB.NET form which I'm displaying modally using the ShowDialog() method. Within the form is a Cancel button, and I've set this button into the Form's CancelButton property so that...
0
by: MikeY | last post by:
Hi everyone, I posted a question very early today, but maybe I wasn't articulate enough. Hopefully this will illicit a response I've created a windows form and a User Control. This is a...
8
by: erick-flores | last post by:
Hello all My code used to work, but now its not working any more. What I am trying to do is find the current user when a forms open. This is the code that used to work: If...
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...
3
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window...
2
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All, I am trying to determine if the user clicked the "x" close button within the controlbox of the form (top right corner - next to minimize and maximize buttons). I am using the...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.