Onevent>DIALOG_EVENT... Close dialog discussion

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

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

Onevent>DIALOG_EVENT... Close dialog discussion

Post by JRL » Fri Oct 30, 2009 7:12 pm

OnEvent Help wrote:DIALOG_EVENT
EventParm is the dialog name. ExtraParm is a modal result value to detect. This could be the modal result of a button or menu option. So when that button is pressed the subroutine is triggered.
Notice that DIALOG_EVENT Help says nothing about the little "X" in the upper right hand corner of the dialog.

Even though GetDialogAction>DialogName,result will set the result variable to "2" when the named dialog upper right "X" is clicked, this is not the case with Onevent>DIALOG_EVENT...
If you have an OnEvent setup something like this:

Code: Select all

Onevent>DIALOG_EVENT,DialogName,2,Close
SRT>Close
  Exit>0
END>Close
You will need to have a button with a return value of "2" to be able to exit your script by clicking on a dialog. Clicking on the "X" does not trigger the DIALOG_EVENT OnEvent>.

If you run the following script and pick the upper right hand "X", the dialog will close but the script will not close. If you instead pick the button which has a return value "2", the dialog and script both close.

Code: Select all

OnEvent>DIALOG_EVENT,Dialog1,2,Close

SRT>Close
  Exit>0
END>Close

Dialog>Dialog1
   Caption=Dialog1
   Width=445
   Height=250
   Top=181
   Left=CENTER
   Max=0
   Min=0
   Resize=0
   Button=Cancel,171,186,75,25,2
EndDialog>Dialog1

Dialog>Dialog3
   Caption=Dialog3
   Width=229
   Height=74
   Top=181
   Left=CENTER
   Max=0
   Min=0
   Close=0
   Resize=0
EndDialog>Dialog3

Show>dialog1
Show>dialog3

Label>Loop
  Wait>0.01
Goto>Loop
I'm not criticizing this functionality, only pointing it out for the benefit of others since it was not obvious to me and took a moment to decipher.

Hope this is helpful,
Dick

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