NSIS:如何获得完成和下一步按钮?
NSIS: How to get a finish- and a next-button?
我用的是MUI_PAGE_INSTFILES
。这个页面通常有一个完成按钮,但我在它后面有一个自定义页面。但我希望您仍然可以在自定义页面之前完成安装程序,而下一页只是可选的。如果需要,我还可以显示更多代码。
!include "MUI2.nsh"
!insertmacro MUI_PAGE_LICENSE $(license)
!insertmacro MUI_PAGE_INSTFILES
Page custom TestSettings
目前我在 instfile 页面上有上一个、下一个和取消按钮。但我想要一个上一个、下一个和完成按钮。
NSIS 从未设计为支持此功能,但使用 ButtonEvent plug-in 您可以让它工作。我只是不确定它是否有意义,因为如果最后一页很重要,那么某些用户可能会因为没有注意而意外跳过该页面。
!include MUI2.nsh
!insertmacro MUI_PAGE_LICENSE $(license)
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstFilesLeave
!insertmacro MUI_PAGE_INSTFILES
Page custom TestSettings
!insertmacro MUI_LANGUAGE English
!include WinMessages.nsh
!include nsDialogs.nsh
Function InstFilesLeave
GetDlgItem [=10=] $hWndParent 2
ShowWindow [=10=] 0
System::Call 'USER32::GetWindowRect(pr0,@r1)' ; NSIS 3+
System::Call 'USER32::MapWindowPoints(p0,p $hWndParent, p , i 2)'
System::Call '*(i.r2,i.r3,i.r4,i.r5)'
IntOp -
IntOp -
!define IDC_MYFINISHBTN 1337
System::Call 'USER32::CreateWindowEx(i 0, t "BUTTON", t "&Finish", i ${DEFAULT_STYLES}|${WS_TABSTOP}, ir2, ir3, i r4, i r5, p $hWndParent, p ${IDC_MYFINISHBTN}, p 0, p 0)p.r1'
SendMessage [=10=] ${WM_GETFONT} "" "" [=10=]
SendMessage ${WM_SETFONT} [=10=] 1
GetFunctionAddress [=10=] OnFinishButton
ButtonEvent::AddEventHandler ${IDC_MYFINISHBTN} [=10=]
FunctionEnd
Var JustFinish
Function OnFinishButton
StrCpy $JustFinish 1
SendMessage $hWndParent ${WM_COMMAND} 1 ""
FunctionEnd
Function TestSettings
StrCmp $JustFinish "" +2
Return
GetDlgItem [=10=] $hWndParent ${IDC_MYFINISHBTN}
ShowWindow [=10=] 0
GetDlgItem [=10=] $hWndParent 2
ShowWindow [=10=] 1
!insertmacro MUI_HEADER_TEXT "Configure" "Blah blah blah"
nsDialogs::Create 1018
Pop [=10=]
; ...
nsDialogs::Show
FunctionEnd
如果您的自定义页面只包含几个复选框,那么您可以 代替。
我用的是MUI_PAGE_INSTFILES
。这个页面通常有一个完成按钮,但我在它后面有一个自定义页面。但我希望您仍然可以在自定义页面之前完成安装程序,而下一页只是可选的。如果需要,我还可以显示更多代码。
!include "MUI2.nsh"
!insertmacro MUI_PAGE_LICENSE $(license)
!insertmacro MUI_PAGE_INSTFILES
Page custom TestSettings
目前我在 instfile 页面上有上一个、下一个和取消按钮。但我想要一个上一个、下一个和完成按钮。
NSIS 从未设计为支持此功能,但使用 ButtonEvent plug-in 您可以让它工作。我只是不确定它是否有意义,因为如果最后一页很重要,那么某些用户可能会因为没有注意而意外跳过该页面。
!include MUI2.nsh
!insertmacro MUI_PAGE_LICENSE $(license)
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstFilesLeave
!insertmacro MUI_PAGE_INSTFILES
Page custom TestSettings
!insertmacro MUI_LANGUAGE English
!include WinMessages.nsh
!include nsDialogs.nsh
Function InstFilesLeave
GetDlgItem [=10=] $hWndParent 2
ShowWindow [=10=] 0
System::Call 'USER32::GetWindowRect(pr0,@r1)' ; NSIS 3+
System::Call 'USER32::MapWindowPoints(p0,p $hWndParent, p , i 2)'
System::Call '*(i.r2,i.r3,i.r4,i.r5)'
IntOp -
IntOp -
!define IDC_MYFINISHBTN 1337
System::Call 'USER32::CreateWindowEx(i 0, t "BUTTON", t "&Finish", i ${DEFAULT_STYLES}|${WS_TABSTOP}, ir2, ir3, i r4, i r5, p $hWndParent, p ${IDC_MYFINISHBTN}, p 0, p 0)p.r1'
SendMessage [=10=] ${WM_GETFONT} "" "" [=10=]
SendMessage ${WM_SETFONT} [=10=] 1
GetFunctionAddress [=10=] OnFinishButton
ButtonEvent::AddEventHandler ${IDC_MYFINISHBTN} [=10=]
FunctionEnd
Var JustFinish
Function OnFinishButton
StrCpy $JustFinish 1
SendMessage $hWndParent ${WM_COMMAND} 1 ""
FunctionEnd
Function TestSettings
StrCmp $JustFinish "" +2
Return
GetDlgItem [=10=] $hWndParent ${IDC_MYFINISHBTN}
ShowWindow [=10=] 0
GetDlgItem [=10=] $hWndParent 2
ShowWindow [=10=] 1
!insertmacro MUI_HEADER_TEXT "Configure" "Blah blah blah"
nsDialogs::Create 1018
Pop [=10=]
; ...
nsDialogs::Show
FunctionEnd
如果您的自定义页面只包含几个复选框,那么您可以