What is the best way to close a modal dialog?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
reimon9
Newbie
Posts: 14
Joined: Mon Oct 01, 2007 9:15 pm

What is the best way to close a modal dialog?

Post by reimon9 » Tue May 08, 2012 4:54 pm

Hello !!!

What is the best way to close a modal dialog?

Greetings,

Reimon

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed May 09, 2012 4:41 am

The "best" way is the way that suits the script and what you as the script author want to accomplish. The following demonstrates two easy ways to close a modal dialog.

Code: Select all

//Simple dialog block
Dialog>Dialog1
object Dialog1: TForm
  Caption = 'Modal Dialog'
  object MSButton1: tMSButton
    Width = 75
    Height = 25
    Caption = 'Close'
  end
end
EndDialog>Dialog1

//Dialog handler defining what to do when the button is clicked
AddDialogHandler>Dialog1,msButton1,OnClick,CloseDialog1

//Display modal dialog
//When the subroutine ends the script returns here.
Show>dialog1,res1

//Picking "X" to close the dialog bypasses the modal Show>
MessageModal>Dialog1 was closed by clicking "X"

//Subroutine to execute when the button is clicked
SRT>CloseDialog1
  //Close the dialog
  CloseDialog>Dialog1
  MessageModal>Dialog1 was closed by clicking the button
  //Reopen the dialog
  Show>dialog1
END>CloseDialog1

reimon9
Newbie
Posts: 14
Joined: Mon Oct 01, 2007 9:15 pm

Post by reimon9 » Thu May 10, 2012 10:46 am

Dear JRL.

Thank you very much.

Greetings,

Reimon

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts