VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 6

Using the Unload and QueryUnload Events in an MDI Application

As we note in "Initialize, Load, and Activate Events", a form's QueryUnload event happens before its Unload event. Both QueryUnload and Unload event procedures receive a Cancel parameter that you can programmatically set to True to stop the form from unloading.

When you attempt to unload the main MDI form in an MDI application, VB unloads all the open Child forms first. This means that the various Unload and QueryUnload events have a special timing relationship in an MDI application. When there is an attempt to unload the main MDI form, the order of the Unload and QueryUnload events is as follows:

  1. The MDI form's QueryUnload event

  2. The QueryUnload event of each open Child form

  3. The Unload event of each Child form

  4. The Unload event of the MDI form

If Cancel is set to True within any of these event procedures, the entire unloading process stops. If unloading is halted during any of the QueryUnload event procedures, then none of the Unload events is triggered, and no form is unloaded. If unloading is halted during any of the Unload event procedures, then only forms whose Unload events happened before the one where the Cancel occurred will unload.


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved