【问题标题】:NSIS: How to get a finish- and a next-button?NSIS:如何获得完成按钮和下一步按钮?
【发布时间】:2019-07-19 12:05:50
【问题描述】:

我使用MUI_PAGE_INSTFILES。这个页面通常有一个完成按钮,但我后面有一个自定义页面。但是我希望您仍然可以在自定义页面之前完成安装程序,并且下一页只是可选的。如果愿意,我还可以显示更多代码。

!include "MUI2.nsh"

!insertmacro MUI_PAGE_LICENSE $(license)
!insertmacro MUI_PAGE_INSTFILES
Page custom TestSettings

目前我在 instfile 页面上有一个上一个、下一个和取消按钮。但我想要一个上一个、下一个和完成按钮。

【问题讨论】:

    标签: installation nsis nsis-mui


    【解决方案1】:

    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 $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
    

    如果您的自定义页面只包含几个复选框,那么您可以改为 use the MUI Finish page with custom texts

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-26
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-03
      相关资源
      最近更新 更多