我正在尝试在安装文件夹中创建一个数据源文件。我正在使用nsDialogs。在输入用户名和密码之前,不应启用“安装/下一步”按钮。
!include "MUI2.nsh"
Name database
OutFile database.exe
InstallDir $DESKTOP
!insertmacro MUI_PAGE_COMPONENTS
Page custom pgPageCreate pgPageLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Var Dialog
Var TextUser
Var TextPass
Section /o "Data Source" datasource
CreateDirectory "$INSTDIR\datasource"
FileOpen $3 "$INSTDIR\datasource\datasource.properties" w
FileWrite $3 username=$1$\n
FileWrite $3 password=$2$\n
FileClose $3
SectionEnd
Function pgPageCreate
${IfNot} ${SectionIsSelected} ${datasource}
Abort
${EndIf}
!insertmacro MUI_HEADER_TEXT "Database Settings" "Provide MySQL config details."
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 20% 26u 20% 10u "Username:"
Pop $0
${NSD_CreateText} 40% 24u 40% 12u ""
Pop $TextUser
${NSD_CreateLabel} 20% 62u 20% 10u "Password:"
Pop $0
${NSD_CreatePassword} 40% 60u 40% 12u ""
Pop $TextPass
nsDialogs::Show
FunctionEnd
Function PgPageLeave
${NSD_GetText} $TextUser $1
${NSD_GetText} $TextPass $2
FunctionEnd
如何禁用此安装按钮。我找不到任何解决方案。预先感谢。
答案 0 :(得分:0)
使用NSD_OnChange回调:
!include LogicLib.nsh
!include nsDialogs.nsh
#!include MUI2.nsh
Page Custom pgPageCreate pgPageLeave
Page InstFiles
Var hTextUser
Var hTextPass
Var User
Var Pass
Function OnLoginInfoChanged
Pop $0 ; Throw away handle we don't need
${NSD_GetText} $hTextUser $1
${NSD_GetText} $hTextPass $2
GetDlgItem $0 $hWndParent 1 ; Get button handle
${If} "$1" == ""
${OrIf} "$2" == ""
EnableWindow $0 0
${Else}
EnableWindow $0 1
${EndIf}
FunctionEnd
Function pgPageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateText} 40% 24u 40% 12u "$User"
Pop $hTextUser
${NSD_OnChange} $hTextUser OnLoginInfoChanged
${NSD_CreatePassword} 40% 60u 40% 12u "$Pass"
Pop $hTextPass
${NSD_OnChange} $hTextPass OnLoginInfoChanged
Push ""
Call OnLoginInfoChanged ; Simulate change event to initialize the button
nsDialogs::Show
FunctionEnd
Function PgPageLeave
${NSD_GetText} $hTextUser $User
${NSD_GetText} $hTextPass $Pass
FunctionEnd
Section
DetailPrint $User:$Pass
SectionEnd