|
-
Jun 5th, 2010, 04:01 PM
#8
Re: The "X" Button
 Originally Posted by weirddemon
FormClosing. You can e.Cancel = True, clean up, and the call Me.Close
Though you may not have to cancel the close. You'll need to play around with it to see what's best.
This doesn't make any sense. If you set e.Cancel to true (which takes effect after the sub has finished) and you call me.Close from inside of it, you're going to get the FormClosing event raised again, where you're setting e.Cancel to True all over again. It'd never let the form close.
What you should do is set e.Cancel to True under 2 conditions: you've prompted the user for confirmation and they choose the cancel the form's close or something fails during the cleanup process and you want to keep the form open a little longer to let the user try closing it again later.
Also, when canceling the FormClosing event, always let the form close if: Windows is shutting down, or the user kills the app from the Taskmanager. Both of these can be tested for under e.CloseReason
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|