Results 1 to 5 of 5

Thread: prevent form closing when form is closing

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    prevent form closing when form is closing

    I am all about questions today, dont know why!

    I am wondering, when the user clicks on the red X button to close the application, the form closing event is raised.

    I am wondering if there is a way to prevent the application from being closed when the user presses the cross button?

    When my application is doing something and during this process the user wants to close the app - a dialog box tells the user that the application is currently doing a process and asks if they still wanna exit - if the answer is no then I want the application to still be up and running and not exit when the answer is "no"

    Currently I've set the e.Cancel = false, which works but then the application form appears to be disposed/closed but i dont want this

    Code:
    DialogResult confirmExit = MessageBox.Show("It appears that there is a recording in progress, are you sure you wish to exit the application?", "Confirm exit?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
    
                if (confirmExit == DialogResult.No)
                {
                    e.Cancel = false;
                }
                else
                {//Whatever....}
    Last edited by Techno; Feb 1st, 2006 at 12:24 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width