Hide main form instead of closing

  • Thread starter Thread starter Matthew
  • Start date Start date
M

Matthew

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
 
In the closing event of the form, do something like this:

Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
Me.Hide()
e.Cancel = True
End Sub

Note that you'll then need to use Application.Exit( ) to exit the
application since closing the form is not going to exit and also calling
Form1.Close won't help since this also fires the Closing event.

hope that helps..
Imran.
 
Matthew,

This is very bad programmers behaviour and your users will not like you.

They are used to there normal habbits, what you want to do is making a car
go to the left when the wheel is turned to the right and let the car speed
up when you push the brakes.

Just my 2 eurocents

Cor
 
In the closing event of the form, do something like this:
Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
Me.Hide()
e.Cancel = True
End Sub

Perfect! Thanks for your help.

Matthew
 
In the closing event of the form, do something like this:
Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
Me.Hide()
e.Cancel = True
End Sub

Perfect! Thanks for your help.

Matthew
 
This is very bad programmers behaviour and your users will not like you.
They are used to there normal habbits, what you want to do is making a car
go to the left when the wheel is turned to the right and let the car speed
up when you push the brakes.

Thanks for the advice. I will keep it in mind.
I think in this instance the users would be disappointed if the [entire]
application closed.
However, I will definitely listen to user feedback and take that feature off
if they don't like it.

Matthew
 

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

Back
Top