簡體   English   中英

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 插件使其工作。 我只是不確定這是否有意義,因為如果最后一頁很重要,那么某些用戶可能會因為沒有注意而意外跳過該頁面。

!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 $0 $hWndParent 2
ShowWindow $0 0
System::Call 'USER32::GetWindowRect(pr0,@r1)' ; NSIS 3+
System::Call 'USER32::MapWindowPoints(p0,p $hWndParent, p $1, i 2)'
System::Call '*$1(i.r2,i.r3,i.r4,i.r5)'
IntOp $4 $4 - $2
IntOp $5 $5 - $3
!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 $0 ${WM_GETFONT} "" "" $0
SendMessage $1 ${WM_SETFONT} $0 1
GetFunctionAddress $0 OnFinishButton
ButtonEvent::AddEventHandler ${IDC_MYFINISHBTN} $0
FunctionEnd

Var JustFinish

Function OnFinishButton
StrCpy $JustFinish 1
SendMessage $hWndParent ${WM_COMMAND} 1 ""
FunctionEnd

Function TestSettings
StrCmp $JustFinish "" +2
    Return
GetDlgItem $0 $hWndParent ${IDC_MYFINISHBTN}
ShowWindow $0 0
GetDlgItem $0 $hWndParent 2
ShowWindow $0 1
!insertmacro MUI_HEADER_TEXT "Configure" "Blah blah blah"
nsDialogs::Create 1018
Pop $0
; ...
nsDialogs::Show
FunctionEnd

如果您的自定義頁面只包含幾個復選框,那么您可以使用帶有自定義文本的 MUI Finish 頁面

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM