Page 1 of 1

How do you know if a non-modal dialog was canceled?

Posted: Wed May 27, 2009 1:25 pm
by jsmith
How can you tell if a non-modal dialog was canceled? The "Return Result in Variable" field of Display Dialog is only applicable to modal dialogs. What about non-modal dialogs?

I've tried checking the value of the built-in ABORT variable after hiding the dialog, but it never hits that code:

Code: Select all

Display Dialog: progress, use as progress dialog (non-modal)

Apply Install (get result into variable SUCCESS)
if Variable SUCCESS not Equals ERROR
  Call DLL Function $TARGETDIR$\\CustomActions.dll->Install (get result into variable CUSTACTSUCCESS)

  if Variable CUSTACTSUCCESS not Equals 0
    Set Variable SUCCESS to ERROR
    Set Variable LASTERROR to Post-Install Actions Failed
    Apply Uninstall
  end
end

Hide Dialog
if Variable ABORT Equals TRUE
  MessageBox: $TITLE$ Setup, User Canceled!  Abort = true!
else
  MessageBox: $TITLE$ Setup, Abort != true
end

Neither of the message boxes are ever displayed. I do see a "Setup canceled" message box, but I believe this is coming from within IA. I am not explicitly displaying this.

How do I capture that a user pressed cancel on a non-modal dialog so that I can perform cleanup and exit cleanly?

Thanks!

Posted: Wed May 27, 2009 1:35 pm
by MichaelNesmith
The Pre-Defined Variables topic in help describes some helpful variables, read up on: ABORT, ABORTONERROR, ABORTEDONERROR - some of these are new for InstallAware 9 and provide enhanced error handling facilities in your MSIcode script.

Also, Apply Changes returns CANCEL when installation has been aborted.

Posted: Wed May 27, 2009 3:38 pm
by jsmith
Thanks Michael. Setting ABORTONERROR to FALSE allows me to clean up when the user cancels.