By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,032 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,032 IT Pros & Developers. It's quick & easy.

Hide main form instead of closing

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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" <tu*************@alltel.net> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

P: n/a
> 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
Nov 21 '05 #4

P: n/a
> 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
Nov 21 '05 #5

P: n/a
> 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
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.