【问题标题】:How can I get a finish button after a nsDialogs page如何在 nsDialogs 页面后获得完成按钮
【发布时间】:2012-02-07 08:07:26
【问题描述】:

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

Page directory
Page instfiles
Page custom nsDialogsPage nsDialogsPageLeave

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

【问题讨论】:

  • 经典的 NSIS UI(又名不使用现代 UI)没有完成页面,您想要单独的完成页面还是只更改自定义页面上的按钮名称?

标签: nsis


【解决方案1】:

经典的 NSIS UI 没有完成页面,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

【讨论】:

  • 是的,我最终将配置屏幕移到了 insfile 之前。不过,我正在考虑尝试将整个内容转换为现代 UI。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-11
  • 1970-01-01
  • 1970-01-01
  • 2016-08-23
  • 1970-01-01
  • 2018-12-13
  • 1970-01-01
相关资源
最近更新 更多