我的要求是在安装NSIS安装程序时,如果用户通过单击“取消”按钮在“欢迎”屏幕中取消了安装过程,则应弹出消息“您确定要取消安装吗?安装”和“是”和“否”按钮。在此处单击“是”时,应中断安装并进入“安装中断”屏幕。
但是在这里,路径(\ NSIS \ Contrib \ Modern UI 2 \ Pages \ Welcome.nsh)中存在Welcome.nsh文件。那么,如何处理“ TestSetup.nsi”文件中“ Welcome.nsh”文件的“取消”事件呢?
更新的代码基于输入:
;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
答案 0 :(得分:0)
不确定为什么您认为需要此功能,但是您可以进行以下操作:
<div class="a">
<div class="b">texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext</div>
</div>
,如果要在多个页面上使用此行为,则:
Var IsOnWelcomePage
!define MUI_CUSTOMFUNCTION_ABORT onAbort
!include MUI2.nsh
!include LogicLib.nsh
Page Custom MySillyPage
!define MUI_PAGE_CUSTOMFUNCTION_SHOW WelShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE WelLeave
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
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 "Blah" "Blah blah"
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 0 100% 12u "Blah blah blah"
Pop $0
nsDialogs::Show
FunctionEnd
Function onAbort
${If} $IsOnWelcomePage <> 0
${If} ${Cmd} ` MessageBox MB_YESNO "Sure?" IDYES `
Call WelLeave
SendMessage $HWNDPARENT 0x408 -1 ""
${EndIf}
Abort
${EndIf}
FunctionEnd