2

Having a NSIS setup with Modern UI 2, the user gets a message box to confirm when he clicks on the Cancel button in the installation wizard.

I want the user to be able to exit the installation wizard without confirming an additional "Are you sure?" dialog message box.

In the MUI sources I found this fragment:

!macro MUI_FUNCTION_ABORTWARNING

  Function .onUserAbort

    !ifdef MUI_PAGE_FUNCTION_ABORTWARNING
      Call ${MUI_PAGE_FUNCTION_ABORTWARNING}
    !endif

    !ifdef MUI_ABORTWARNING
      !insertmacro MUI_ABORTWARNING
    !endif

    !ifdef MUI_CUSTOMFUNCTION_ABORT
      Call "${MUI_CUSTOMFUNCTION_ABORT}"
    !endif
  FunctionEnd

!macroend

I am both able to define the MUI_PAGE_FUNCTION_ABORTWARNING function and the MUI_CUSTOMFUNCTION_ABORT function.

Since the actual message box is defined in the middle call to the MUI_ABORTWARNING macro, I see no way to stop the macro from being called.

My question is:

Is there a way to hinder MUI from showing the user a confirmation message box when he clicks the Cancel button during the setup process?

Machavity
  • 30,841
  • 27
  • 92
  • 100
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291

2 Answers2

3

This warning is controlled by !define MUI_ABORTWARNING (Before you include mui.nsh):

Name "Test"
Outfile "Test.exe"
RequestExecutionLevel user

#Comment/uncomment this to toggle the messagebox: !define MUI_ABORTWARNING

!include MUI2.nsh

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English

Section
SectionEnd
Anders
  • 97,548
  • 12
  • 110
  • 164
  • Thanks, @Anders, I [tried this](http://pastebin.com/HATfCZH8) and it does not seem to work. I click `Cancel` on the welcome page and still get a question whether I want to quit. Since I know the high quality of your answers, I wonder where I made the error in [my script](http://pastebin.com/HATfCZH8). Any ideas? – Uwe Keim Jun 19 '12 at 19:07
  • Sorry, I do not understand; line 12 is the `!define MUI_ABORTWARNING` that you suggested to insert. I'm confused... – Uwe Keim Jun 19 '12 at 19:25
  • This is crazy; the line was not present before, then I added it, now I commented it out and now the message box really disappeared. So it is working right now, although I have no clue why. – Uwe Keim Jun 20 '12 at 04:30
1

(untested) you can try to undefine the corresponding funcs ?

!undef MUI_ABORTWARNING
//or
!undef MUI_FUNCTION_ABORTWARNING
Seki
  • 11,135
  • 7
  • 46
  • 70
  • Thanks, @Seki - I already tried this (and hust tried it again). It keeps giving the error message "`!undef: "MUI_ABORTWARNING" not defined!`" – Uwe Keim Jun 19 '12 at 15:46
  • 3
    MUI_FUNCTION_ABORTWARNING is a macro and cannot be !undef'ed – Anders Jun 19 '12 at 17:42