如何在nsDialogs页面后获得完成按钮

时间:2012-02-06 22:11:35

标签: nsis

我正在尝试使用nsDialogs在我的nsis脚本中创建一个安装后配置页面。我收集输入和执行配置的脚本工作但是我完成后从未提供完成/关闭/退出按钮。目前我的页面声明如下:

Page directory
Page instfiles
Page custom nsDialogsPage nsDialogsPageLeave

如何在nsDialogsPageLeave执行后显示完成/退出/完成按钮?

1 个答案:

答案 0 :(得分:6)

经典的NSIS用户界面没有完成页面,instfiles页面通常是最后一页,它将显示一个"完成按钮"在所有部分都已执行之后。如果您想提供自己的完成页面,可以使用SendMessage $hwndButton ${WM_SETTEXT} 0 "STR:$(^CloseBtn)"将任何按钮的文本设置为相同的字符串。

大多数安装程序在instfiles页面之前请求所需信息,如果你不能这样做,那么你可能想要使用Modern UI,它将为你提供一个完成页面:

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Page custom nsDialogsPage nsDialogsPageLeave
!insertmacro MUI_PAGE_FINISH

如果你想要两页,我有点不清楚;输入页面,然后是完成页面或组合输入/完成页面。组合页面有点奇怪,但有可能:

!define AppName "Test"
Name "${AppName}"
Outfile "${AppName} setup.exe"
InstallDir $temp

!include LogicLib.nsh
!include WinMessages.nsh
!include nsDialogs.nsh

Var MyEndConfigPageStage

Page Directory
Page InstFiles
Page Custom MyEndConfigPageCreate MyEndConfigPageLeave /EnableCancel

Function MyEndConfigPageCreate
StrCpy $MyEndConfigPageStage 0
GetDlgItem $0 $hwndparent 1
SendMessage $0 ${WM_SETTEXT} 0 "STR:&Apply"
nsDialogs::Create 1018
Pop $0
${NSD_CreateCheckBox} 0 13u 100% -13u "FooBar"
Pop $1
nsDialogs::Show
FunctionEnd

Function MyEndConfigPageLeave
${If} $MyEndConfigPageStage > 0
    Return
${EndIf}
${NSD_GetState} $1 $2
ClearErrors
WriteIniStr "$instdir\settings.ini" Dummy "FooBar" $2
${If} ${Errors}
    MessageBox mb_iconstop "Unable to apply settings!"
    Abort
${EndIf}
IntOp $MyEndConfigPageStage $MyEndConfigPageStage + 1
GetDlgItem $0 $hwndparent 1
SendMessage $0 ${WM_SETTEXT} 0 "STR:$(^CloseBtn)"
GetDlgItem $0 $hwndparent 2
EnableWindow $0 0 ;Disable cancel
EnableWindow $1 0 ;Disable the checkbox
Abort
FunctionEnd

Section
SectionEnd
相关问题