How do I prevent an application being closed?

Display a window. Automatically run code. Prevent an application from being closed.

How do I prevent an application being closed?

Postby uberdroid on Wed Jan 14, 2009 10:13 pm

To do this, trap the Unload event of the main window.

If you want to fully prevent the user from closing the application, just return Cancel <- False under the Unload event. This cancels the Unload event and the main window will not be closed. If you do this you will need some other way of ending the application.

You can also give the user the choice of whether to close the application. To do this, use the Unload event to pop-up a Msgbox asking the user to confirm whether they want to quit. If they don't want to quit, set Cancel <- True to cancel the Unload event, but if they do want to quit do nothing and the unload event will run to completion and terminate the application.
Posts: 38
Joined: Wed Jan 14, 2009 4:36 am

Return to Applications and Classes

Who is online

Users browsing this forum: No registered users and 1 guest