Мое требование - при установке установщика NSIS, если пользователь отменил процесс установки в окне «Добро пожаловать», нажав кнопку «Отмена», должно появиться сообщение «Вы уверены, что хотите отменитьустановка "с кнопками" да "и" нет ".И здесь при нажатии «да» установка должна быть прервана и перейти к экрану «прерывание установки».
Но здесь файл Welcome.nsh находится в пути (\ NSIS \ Contrib \ Modern UI 2\ Pages \ Welcome.nsh).Так как же обработать событие «Отмена» файла «Welcome.nsh» в моем файле «TestSetup.nsi»?
Обновленный код На основе входных данных:
;Include Modern UI
Var IsOnWelcomePage
!define MUI_CUSTOMFUNCTION_ABORT onAbort
!include "MUI2.nsh"
Name "EMR 4.0.1"
OutFile "PCPE_4.0.1.exe"
InstallDir "$PROGRAMFILES64\APC\EMR"
InstallDirRegKey HKLM "Software\APC\EMR" "Install_Dir"
; Request application privileges for Windows Vista
; Below line is to check the administrative permissions
RequestExecutionLevel admin
; Below is the include file to check the conditions (If and else)
!include LogicLib.nsh
;--------------------------------
; Pages
;Customizing the Welcome Text
!define MUI_TEXT_WELCOME_INFO_TEXT "The Setup Wizard will install PowerChute Personal Edition on$\r$\n your computer. Click Next to continue or Cancel to exit the$\r$\n Setup Wizard."
!define MUI_WELCOMEFINISHPAGE_BITMAP "C:\Code\Code\PCPE\NULLSOFT\src\Bitmaps\dlgbmp-for-china.bmp"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW WelShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE WelLeave
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\license.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_LICENSE "${NSISDIR}\Docs\Modern UI\license.rtf"
;!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_DIRECTORY
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "PortugueseBR"
; Below is to remove the label NULLsoft installer from the installer screens
BrandingText " "
;--------------------------------
;Installer Functions
;--------------------------------
; The stuff to install
Function WelShow
StrCpy $IsOnWelcomePage 1
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 0 ; Hide Back button
FunctionEnd
Function WelLeave
StrCpy $IsOnWelcomePage 0
FunctionEnd
Function MySillyPage
${IfThen} $IsOnWelcomePage == "" ${|} Abort ${|}
GetDlgItem $0 $HWNDPARENT 1
ShowWindow $0 0 ; Hide Next button
GetDlgItem $0 $HWNDPARENT 2
${NSD_SetText} $0 "$(^CloseBtn)"
!insertmacro MUI_HEADER_TEXT "EMR" "EMR Setup Wizard was interrupted"
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 0 100% 12u "EMR Setup Wizard was interrupted. $\r$\n$\r$\n Click the finish button to exit the Setup Wizard"
Pop $0
nsDialogs::Show
FunctionEnd
Function onAbort
${If} $IsOnWelcomePage <> 0
${If} ${Cmd} ` MessageBox MB_YESNO "Are you sure you want to cancel EMR installation?" IDYES `
Call WelLeave
SendMessage $HWNDPARENT 0x408 -1 ""
${EndIf}
Abort
${EndIf}
FunctionEnd
Section "RegistryTest (required)"
SectionIn RO
; Set output path to the installation directory. Here is the path C:\Program Files\APC\PowerChute Personal Edition
SetOutPath $INSTDIR
....
SectionEnd