I would like to activate a piece of code in my MDI form when the red X button at the upper right is clicked (I don’t know what it is officially called) so that the program closes down nicely.
What method in the Form is invoked when that happens?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Form_QueryUnloadis called. Since you have indicated an MDI application, the exact event invoked isPrivate Sub MDIForm_QueryUnload(cancel As Integer, unloadmode As Integer)where if you set
cancelto a non-zero value inside this function, it stops the application from exiting. In other words,QueryUnloadis a way to query if the form should unload or not. The second argument,unloadmodegives you the information how this unloading was triggered.More help on MSDN.