How the Cancel button works
This help topic refers to a previous version of InstallMate. It has not been updated for InstallMate 11 yet.
All installers have Cancel buttons on each dialog page. There are no general switches and no black magic either as to how these are implemented; they use standard installer actions. This topic explains how.
General operation of the Cancel button
Each dialog box with a Cancel button has an event handler for that button's OnClicked event; see the screen shot below.
This event handler does two things:
- It uses a standard QueryCancel action to ask the user if he/she really wants to cancel;
- If this action returns Yes, it closes the dialog box with the IDCANCEL return code. (If QueryCancel returns No, the event handler action sequence is terminated before it reaches the EndDialog action.)
This logic is present for each dialog box with a Cancel button; to restore it in case you accidentally deleted it, just create a new CancelBtn:OnClicked event handler (right-click on the Cancel button, then choose New Event Handler... and follow the prompts) and add the two actions shown above.
Please note that the EndDialog action in each event handler must close the current dialog (OptionsDlg in the screen shot above).
The role of the UIAllowCancel variable
There is also a variable called UIAllowCancel defined on the Variables project page. This variable is used to determine whether or not cancellation of the installation is allowed once is has started.
By default, only the predefined ProgressDlg dialog box uses this variable. In that dialog box, UIAllowCancel is used to enable or disable the Cancel button using the push button control's Condition field; see the screen shot below.
- If UIAllowCancel is nonzero, then the Cancel button is enabled and the user can press it (after which the CancelBtn:OnClicked event handler is invoked as described earlier).
- If UIAllowCancel is zero, then the Cancel button is disabled and the user cannot interrupt the installation sequence.
Tip: You can use a similar method to selectively enable or disable other dialog boxes or controls.