Needing help with the FormClosing() Event

A

Anthony P.

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_Click() subroutine does one thing: It calls
Application.Exit() (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.Exit() method which, in turn raises the
FormClosing() event.

Can anyone clue me in?

Thanks!
Anthony
 
B

Bill McCarthy

e.ClosingReason in the Form.Closing event should tell you the difference
between the two
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top