Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have noticed with my VB.NET program that when I click on the X in the right corner of the window to close the program it is still running as a process in Windows. How do I stop this from taking place? When I push the X I want it to clear out of Windows completely.

 

I know you can use application.exit to terminate everything but that does not help if somebody hits the X in the right corner.

 

Thank you

Edited by laroberts
Posted
No I can shutdown the application just fine if I use a button for it. Its when a user pushes the X in the right hand corner. I do not want to shutoff the controls up there so there must be a way to take care of that when they push it.
Posted

You probably still have some hidden forms running or something like that. If you want to terminate the application when the user clicks the "X", then

you might want to do an Application.exit or something similar on the closing event for that form. You can even give the user a messagebox first or

just do an Application.exit on the form closing event.

 


Private Sub frmMain_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
       Dim Dgr As DialogResult

       Dgr = MessageBox.Show("Do You Really Want To Exit?", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
       If Dgr = DialogResult.Yes Then
           Application.Exit()
       Else
           e.Cancel = True
       End If
   End Sub

 

-=Simcoder=-

Whatever thy hand findest to do, do it with all thy heart - Jesus
  • Administrators
Posted

Application.Exit will not call any code in a form's Closed or Closing events though - if you have validation / save logic in these events then it will be skipped.

Generally it is better to close down resources when you have finished with them - if you ever get to a point when you have resources allocated that you have forgotten about then your code needs revising.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...