No announcement yet.

Asking the User for Confirmation Before Exiting

  • Filter
  • Time
  • Show
Clear All
new posts

  • Asking the User for Confirmation Before Exiting

    AutoPlay Media Studio 5.0 Knowledge Base

    Asking the User for Confirmation Before Exiting

    Document ID: IR10094
    The information in this article applies to:
    • AutoPlay Media Studio 5.0 Standard Edition
    • AutoPlay Media Studio 5.0 Professional Edition


    This article describes how to display a dialog box asking the user if they want to exit the application.


    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.

    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:

    --this function will be called when the program is exiting

    function QueryAllowProjectClose()

    confirmation = Dialog.Message("Are you sure?", "Are you sure that you want to exit?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);

    --the yes button was pressed

    if confirmation == 6 then

    --allow the program to close

    return true;


    --the no button was pressed

    if confirmation == 7 then

    --tell the program to 'stop closing'

    return false;


    --if for any reason confirmation is not set to yes OR no, allow the program to close

    return true;

    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.

    KEYWORDS: AutoPlay Media Studio 5.0, Window, Application, Close, Exit, Terminate, Confirmation

    Last reviewed: October 3, 2003
    Copyright © 2003 Indigo Rose Corporation. All rights reserved.

  • #2
    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.