473,657 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_QueryUnloa d( 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(By Val eventSender As System.Object, ByVal eventArgs As System.Componen tModel.CancelEv entArgs) 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 1667
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*******@disc ussions.microso ft.com> scripsit:
Form_Closing(By Val eventSender As System.Object, ByVal eventArgs As System.Componen tModel.CancelEv entArgs) 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

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

Similar topics

3
2567
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 started, but i would like to do it automatcally so i do not have to worry about any threads that remain active after i closed the form.
1
1219
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 multiuser application. Following is the architecture of the application ...
5
3012
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 CancelEventArgs that lets me cancel the Close() operation, but is there still any way to find out *why* a form is closing? This app as a form that needs to be loaded at startup, closed only at shutdown, and then Show() / Hide() for the user. If...
5
15752
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 pressing Escape automatically clicks the button. Within the button's Click event code I display a confirmation messagebox to ensure the user really does want to cancel. However, regardless of what code I put in this event, the dialog form always...
0
1309
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 keyboard. What I have done is that every keystroke is entered into a textbox within my User Control. Want I want to do is to take that user input from keyboard textbox and display it within my main form. I also want to be able to close this control and...
8
1679
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 faq_IsUserInGroup("Admins", CurrentUser) Then Me.RecordSource = "SELECT * FROM Employees" DoCmd.FindRecord (CurrentUser) <----------------------------------------------------
14
3357
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 I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
3
2782
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 (not web-based or part of current application) brought to the front and focused (findwindow api) and have the button scrape the contents of the focused window so the contents can be parsed and entered into the web application. Ideally, I would...
2
4955
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 datagridview within VB2005. I validate the values in the row when the user leaves the row via the grid's RowValidating event. I want to allow the user to exit the application by clicking the "x".
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.