禁用下一个按钮,直到 nsDialogs 填满
Disable next button until nsDialogs filled
我正在尝试在安装文件夹中创建数据源文件。我正在使用 nsDialogs。在输入用户名和密码之前,不应启用 Install/Next 按钮。
!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 "$INSTDIR\datasource\datasource.properties" w
FileWrite username=$\n
FileWrite password=$\n
FileClose
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 [=10=]
${NSD_CreateText} 40% 24u 40% 12u ""
Pop $TextUser
${NSD_CreateLabel} 20% 62u 20% 10u "Password:"
Pop [=10=]
${NSD_CreatePassword} 40% 60u 40% 12u ""
Pop $TextPass
nsDialogs::Show
FunctionEnd
Function PgPageLeave
${NSD_GetText} $TextUser
${NSD_GetText} $TextPass
FunctionEnd
如何禁用此安装按钮。我找不到任何解决方案。提前致谢。
使用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 [=10=] ; Throw away handle we don't need
${NSD_GetText} $hTextUser
${NSD_GetText} $hTextPass
GetDlgItem [=10=] $hWndParent 1 ; Get button handle
${If} "" == ""
${OrIf} "" == ""
EnableWindow [=10=] 0
${Else}
EnableWindow [=10=] 1
${EndIf}
FunctionEnd
Function pgPageCreate
nsDialogs::Create 1018
Pop [=10=]
${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
我正在尝试在安装文件夹中创建数据源文件。我正在使用 nsDialogs。在输入用户名和密码之前,不应启用 Install/Next 按钮。
!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 "$INSTDIR\datasource\datasource.properties" w
FileWrite username=$\n
FileWrite password=$\n
FileClose
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 [=10=]
${NSD_CreateText} 40% 24u 40% 12u ""
Pop $TextUser
${NSD_CreateLabel} 20% 62u 20% 10u "Password:"
Pop [=10=]
${NSD_CreatePassword} 40% 60u 40% 12u ""
Pop $TextPass
nsDialogs::Show
FunctionEnd
Function PgPageLeave
${NSD_GetText} $TextUser
${NSD_GetText} $TextPass
FunctionEnd
如何禁用此安装按钮。我找不到任何解决方案。提前致谢。
使用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 [=10=] ; Throw away handle we don't need
${NSD_GetText} $hTextUser
${NSD_GetText} $hTextPass
GetDlgItem [=10=] $hWndParent 1 ; Get button handle
${If} "" == ""
${OrIf} "" == ""
EnableWindow [=10=] 0
${Else}
EnableWindow [=10=] 1
${EndIf}
FunctionEnd
Function pgPageCreate
nsDialogs::Create 1018
Pop [=10=]
${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