NSIS:从函数调用 MUI_PAGE_LICENSE 但出现 "XPStyle not valid" 错误

NSIS: call MUI_PAGE_LICENSE from function but get "XPStyle not valid" error

我有一个带有 "License terms and conditions." 复选框的自定义对话框,其中复选框的文本实际上是一个 link,它应该显示许可对话框。

; === LicenseLink (type: Link) ===
${NSD_CreateLink} 132.96u 100.92u 107.29u 14.15u "License terms and conditions."
Pop $hCtl_welcome_LicenseLink
${NSD_OnClick} $hCtl_welcome_LicenseLink ShowLicense

现在在函数 "ShowLicense" 中我尝试调用

!insertmacro MUI_PAGE_LICENSE

但是报错: 错误:命令 XPStyle 在函数

中无效

显然我处理这个错误,我无法解释错误。很高兴有任何关于如何解决这个问题的想法。

谢谢!

不能动态调用!insertmacro MUI_PAGE_LICENSE,页数在编译时决定。

但是您可以跳过页面来实现此目的:

InstallDir "$Temp\Test"

!include MUI2.nsh
!include nsDialogs.nsh
!include WinMessages.nsh
!include LogicLib.nsh

!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipLicensePage
!insertmacro MUI_PAGE_LICENSE "${__FILE__}"
Page Custom InfoPageCreate InfoPageValidate
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English


Var ShowLicensePage
Function SkipLicensePage
${IfThen} $ShowLicensePage = 0 ${|} Abort ${|} ; Skip it the first time
FunctionEnd

Function OnShowLicense
SendMessage $hWndParent ${WM_COMMAND} 3 "" ; Click the (hidden) back button
FunctionEnd

Var InstDirCtl
Function InfoPageCreate
StrCpy $ShowLicensePage 1
GetDlgItem [=10=] $hWndParent 3
ShowWindow [=10=] 0 ; Hide the back button
!insertmacro MUI_HEADER_TEXT "Blah blah" "blah blah blah"
nsDialogs::Create 1018
Pop [=10=]

${NSD_CreateText} 0 13u 100% 12u "$InstDir"
Pop $InstDirCtl

${NSD_CreateLink} 2u 40u -4u 12u "License"
Pop [=10=]
${NSD_OnClick} [=10=] OnShowLicense

nsDialogs::Show
FunctionEnd

Function InfoPageValidate
${NSD_GetText} $InstDirCtl $InstDir
FunctionEnd