473,766 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Needing help with the FormClosing() Event

Hello Everyone,

I'm writing an application that will reside in the system tray once it
is configured. The application also has an exit button called,
creatively, ExitButton. I'm in a bit of a pickle here and not sure how
to solve it. Here's the deal:

When the user clicks the X in the forms control box (which fires the
FormClosing() event) I minimize the form to the service tray. That
works.

Now, when the user clicks the button (ExitButton) the
ExitButton_Clic k() subroutine does one thing: It calls
Application.Exi t() (which of course...fires the FormClosing() event).

See the problem?

So I need a way to distinguish what is generating the FormClosing()
event: the button or the click on the control box. Both seem to be
firing the Application.Exi t() method which, in turn raises the
FormClosing() event.

Can anyone clue me in?

Thanks!
Anthony

Sep 1 '08 #1
2 2345
e.ClosingReason in the Form.Closing event should tell you the difference
between the two
"Anthony P." <pa*******@gmai l.comwrote in message
news:36******** *************** ***********@73g 2000hsx.googleg roups.com...
Hello Everyone,

I'm writing an application that will reside in the system tray once it
is configured. The application also has an exit button called,
creatively, ExitButton. I'm in a bit of a pickle here and not sure how
to solve it. Here's the deal:

When the user clicks the X in the forms control box (which fires the
FormClosing() event) I minimize the form to the service tray. That
works.

Now, when the user clicks the button (ExitButton) the
ExitButton_Clic k() subroutine does one thing: It calls
Application.Exi t() (which of course...fires the FormClosing() event).

See the problem?

So I need a way to distinguish what is generating the FormClosing()
event: the button or the click on the control box. Both seem to be
firing the Application.Exi t() method which, in turn raises the
FormClosing() event.

Can anyone clue me in?

Thanks!
Anthony
Sep 1 '08 #2
On Sep 1, 2:18*am, "Bill McCarthy" <B...@localhost .comwrote:
e.ClosingReason in the Form.Closing event should tell you the difference
between the two
Thank you!
Sep 2 '08 #3

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

Similar topics

0
1222
by: Frank | last post by:
Hello, in the formClosing event I put an endEdit for the datagridview. Works fine. Except when the cursor is on the line for a new record. That gives errors because some fields are not filled (and never will be). How could I prevent this? I could check if it's the last line, but in some cases the users could have filled the last line properly and would like to store it. So skipping the endedit in this case is not a good idea. Any ideas?...
1
3269
by: e_man_online | last post by:
Hi, I have a VStudio 2003 project that had code like: Private Sub frmAnyForm_Closing(<parameters list...>) Handles MyBase.Closing and this project was converted to .NET 2.0 Everything compiled and worked no warnings or errors are left, but I realized that the closing event in .NET 2.0 has changed to:
4
7730
by: Academic | last post by:
I read the Help and some of the many Google hits I got but can't find out the difference between MyBase.Closing and MyBase.FormClosing Can anyone tell me? Thanks
13
2950
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the events.. But the regular forms that are also open do not receive that event. This is true whether there are child forms open or not.
1
5149
by: dani kotlar | last post by:
Is it possible to suspend the closing of a form from the FormClosing event handler, or any other way? Thanks
2
1504
by: feltra | last post by:
Hi, The following is from my friend, who has some technical problem at present in accessing the web... I am writing for him... Kindly request your inputs ASAP, as he has some kind of deadline tomorrow. .......................................................................................... I am having an issue with MDI form. I have an MDI form and some Child forms. In order to enable for a choice, I am displaying a message box in...
0
1112
by: Vivek | last post by:
I am having an issue with MDI form. I have an MDI form and some Child forms. In order to enable for a choice, I am displaying a message box in the FormClosing event of both the forms. When the form is closed individually, the code works fine, closing the form depending on confirmation from the user, other wise the e.Cancel event is set to true. The problem is when I try to close the MDI form when the child forms are open. By virtue of the...
8
2023
by: AAaron123 | last post by:
If I show a form with ShowDialog and Dispose it FormClosing does not appear to run. At least I think that is true. If I want FormClosing and FormClose to run am I suppose to call the forms Close method?
5
991
by: govolsbaby | last post by:
Not sure how to ask this so I'll try a couple ways. So I have a class with an event... Public Class myClass Public Event SomethingsGoingOn() Private Sub SomethingHappened(ByVal sender As Object, ByVal e As System.EventArgs) Handles Something.Happened 'code here changes some properties of myClass RaiseEvent SomethingsGoingOn()
0
9568
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
9404
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
10008
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 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...
0
9837
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...
1
7381
isladogs
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...
0
6651
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
5279
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
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
bsmnconsultancy
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...

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.