I've been looking but can't find out how in a form Closing event to know if
the closing is because the form's "X" had been clicked or the main form's
"X" was clicked.
That is, I need to know if just the form is closing or the application is
closing.
Do you know how to tell?
Thanks 6 1676
**Developer** wrote: I've been looking but can't find out how in a form Closing event to know if the closing is because the form's "X" had been clicked or the main form's "X" was clicked.
That is, I need to know if just the form is closing or the application is closing.
Do you know how to tell?
I had this same puzzle - I just set a global flag when the program is
closing, so the form can check it.
Tom Thanks
> I had this same puzzle - I just set a global flag when the program is closing, so the form can check it.
I do the same thing. In simple apps, it doesn't matter much. But with
several forms and/or several threads and/or several open resources, you are
kind of fixed. An-app wide shutting down flag seems like the simplest
solution.
> How do you set the flag.
I set it in the main form's closing event handler. I believe the other form's Closing event occurs before the main form's closing event.
In my apps, if I close the main window, its closing event fires first,
shutdown is indicated, and then secondary windows close. If I close a
secondary window, its closing event fires, but nothing else happens.
I'm working on a MDI app.
It has forms that are non-MDI child and some that are.
The non-MDI child work as you say but the child always closes first.
You said "shutdown is indicated."
How do you check that?
Maybe I can use that somehow.
Thanks
"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:E3******** *************** ***********@mic rosoft.com... How do you set the flag.
I set it in the main form's closing event handler.
I believe the other form's Closing event occurs before the main form's closing event.
In my apps, if I close the main window, its closing event fires first, shutdown is indicated, and then secondary windows close. If I close a secondary window, its closing event fires, but nothing else happens.
> I'm working on a MDI app.
No experience with mdi. Perhaps events fire differently? You said "shutdown is indicated." How do you check that?
In a public module, declare the shutdown flag, something like:
Public Module SomeNameYourCho ice
Public AppIsShuttingDo wn As Boolean = False
End Module
In the main form's closing event:
AppIsShuttingDo wn = True
In other places that need to know if the app is shutting down or not:
If AppIsShuttingDo wn Then
' whatever you want if shutting down
Else
' whatever you want if not shutting down
Endif
Thanks
I knew how to do that.
I was hoping one of the Closing event arguments had a clue or maybe the
Application class did.
I had looked but couldn't find anything.
Thanks again
"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:C0******** *************** ***********@mic rosoft.com... I'm working on a MDI app.
No experience with mdi. Perhaps events fire differently?
You said "shutdown is indicated." How do you check that?
In a public module, declare the shutdown flag, something like:
Public Module SomeNameYourCho ice Public AppIsShuttingDo wn As Boolean = False End Module
In the main form's closing event:
AppIsShuttingDo wn = True
In other places that need to know if the app is shutting down or not:
If AppIsShuttingDo wn Then ' whatever you want if shutting down Else ' whatever you want if not shutting down Endif This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RAJ |
last post by:
hi
plz tell me how to know "how window is going to close"...
i have to right code for X button of forms...
plz telll me
thanks
bye
|
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 MDI child window.
My application does certain logic when the user actually closes the MDI
child form by clicking the "X" in the upper right hand. My application,
however, should not execute this logic if the user closes the MDI parent. I...
|
by: Stephen Lamb |
last post by:
I have a background worker thread which I start from a form's HandleCreated
event that makes calls back to the form using Invoke. During shutdown the
form is disposed and the background worker thread is aborted by the system.
How is one to keep the background thread from calling form.Invoke after the
form's window handle has been destroyed? This is definitely happening in my
application. I haven't read anything about this problem in...
|
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();
|
by: nadeem_far |
last post by:
Hello All,
I am working on a .Net desktop application and I am having problem
displaying a form. I am using C# and version 1.1 of the framework. here
is how the code looks likes and I will appreciate if someone can tell
me how to resolve this problem.
Main ( Args )
{
Form1 f1 = new Form1();
| |
by: Brad Allison |
last post by:
Is there an easy way to close one form when another opens?
Thanks for the information.
Brad
|
by: Cedric |
last post by:
Hello,
I have a form that could be closed by a code keyed or selected in a combobox
but when I select my code my program end up with an error
(NullReferenceException) and not when I keying the code.
So Does anybody have an explanation ?
Here is a sample to try :
START CLASS :
Public Class Class1
|
by: Matthew |
last post by:
I would like to make it so when a user clicks the X in the upper right
corner it hides the form instead of closing it. I have an icon in the
system tray, and other forms running. If the main form closes, these exit
as well.
Can this be done?
Matthew
|
by: Amy |
last post by:
Hi,
I'm using vs 2005 to develop a mobile application. I have tried to use a
closing event to pop up a messagebox before close the form. It seems that the
form is hided. And I found out that the messagebox will occure after clinking
the setting -> memory -> application.
Besides, I have tried the event disposed, closed, too. It seems that it
doesnt pop up the messagebox.
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |