PDA

View Full Version : Asking the User for Confirmation Before Exiting


Desmond
10-03-2003, 03:56 PM
<HTML> <HEAD> <TITLE>AutoPlay Media Studio 5.0 Knowledge Base</TITLE> </HEAD> <BODY> <h3>Asking the User for Confirmation Before Exiting</h3> <b>Document ID: IR10094</b> <hr> The information in this article applies to: <ul> <li>AutoPlay Media Studio 5.0 Standard Edition</li> <li>AutoPlay Media Studio 5.0 Professional Edition</li> </ul> <hr> <h3>SUMMARY</h3> <p>This article describes how to display a dialog box asking the user if they want to exit the application.</p> <h3>DISCUSSION</h3> <p> In AutoPlay Media Studio 5.0, it is possible to stop closing your application based on user input, even after the close button has been pressed, or the Application.Exit action has been used. This is useful if, for example, you are worried that the user will accidentally close your application, or if you want to allow the user to save their changes before they exit.<br> <br> To accomplish this, you must include a function (QueryAllowProjectClose) in your Global Functions (Project > Global Functions) that returns true if the program should close, and false if it should not: <pre><code>--this function will be called when the program is exiting
<br />function QueryAllowProjectClose()
<br /> confirmation = Dialog.Message("Are you sure?", "Are you sure that you want to exit?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
<br />
<br /> --the yes button was pressed
<br /> if confirmation == 6 then
<br /> --allow the program to close
<br /> return true;
<br /> end
<br />
<br /> --the no button was pressed
<br /> if confirmation == 7 then
<br /> --tell the program to 'stop closing'
<br /> return false;
<br /> end
<br />
<br /> --if for any reason confirmation is not set to yes OR no, allow the program to close
<br /> return true;
<br />end</code></pre>Please note that this function is called internally by your application when it is told to exit. If true is returned, your application will exit. If false is returned, your program will not exit. <p>KEYWORDS: AutoPlay Media Studio 5.0, Window, Application, Close, Exit, Terminate, Confirmation </p> <hr> <FONT SIZE=1> Last reviewed: October 3, 2003<br> Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.<br> </FONT> </BODY> </HTML>

Intrigued
12-11-2005, 07:53 PM
Two Questions:

1. Does this have anything to do with #WM_KILLFOCUS?

2. Can we get more of these tidbits (now for AMS 6)?

Thanks on both fronts in advance, regardless of the turnout.

Sincerely,