简体   繁体   English

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

[英]How can I get a finish button after a nsDialogs page

I'm trying to create a post install configuration page in my nsis script using nsDialogs. 我正在尝试使用nsDialogs在nsis脚本中创建安装后配置页面。 My script for gathering the input and executing the configuration works however I'm never presented with a finish/close/exit button after I'm done. 我的用于收集输入和执行配置的脚本可以运行,但是完成后再也不会显示完成/关闭/退出按钮。 Currently my pages declaration looks like: 目前,我的页面声明看起来像:

Page directory
Page instfiles
Page custom nsDialogsPage nsDialogsPageLeave

How can I get a finish/exit/done button to show after nsDialogsPageLeave executes? nsDialogsPageLeave执行后,如何显示完成/退出/完成按钮?

The classic NSIS UI does not have a finish page, the instfiles page is usually the last page and it will show a "finish button" after all the sections have executed. 经典的NSIS UI没有完成页面,instfiles页面通常是最后一页,并且在所有部分执行完后将显示“完成按钮”。 You can set the text of any button to the same string with SendMessage $hwndButton ${WM_SETTEXT} 0 "STR:$(^CloseBtn)" if you want to provide your own finish page. 如果要提供自己的完成页面,则可以使用SendMessage $hwndButton ${WM_SETTEXT} 0 "STR:$(^CloseBtn)"将任何按钮的文本设置为相同的字符串。

Most installers request the required information before the instfiles page, if you cannot do this then you might want to use the Modern UI , it will provide a finish page for you: 大多数安装程序会在instfiles页面之前请求所需的信息,如果您无法执行此操作,则可能要使用Modern UI ,它将为您提供一个完成页面:

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

It was a little unclear to me if you wanted two pages; 如果您要两页,对我来说还不太清楚。 a input page and then a finish page or a combined input/finish page. 输入页面,然后是完成页面或组合的输入/完成页面。 A combined page is a little weird but it is possible: 合并的页面有点奇怪,但是可能:

!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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM