添加 link 到 MUI_PAGE_INSTFILES 不显示
Added link to MUI_PAGE_INSTFILES does not show
我正在尝试创建一个也有 "Download manually" link 的下载器,但 link 似乎没有显示。
我尝试按照 this post 的说明进行操作,但似乎无法正常工作。
我将脚本复制到这里,以防有人指出我可能遗漏的内容 - 抱歉,我是 NSIS 脚本的菜鸟。
!include "MUI2.nsh"
!define NAME "instfileslink"
Name "${NAME}"
OutFile "${NAME}.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyInstFilesShow
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Var hCtl_test_Link1
Section
Section
inetc::get /caption "Downloading package" "http://speedtest.ftp.otenet.gr/files/test100Mb.db" "test100Mb.db" /end
Pop $R0
StrCmp $R0 "OK" 0 dlfailed
Quit
dlfailed:
DetailPrint "Download failed: $R0"
Abort
SectionEnd
Function fnLinkClicked
ExecShell "open" "http://speedtest.ftp.otenet.gr/files/test100Mb.db"
FunctionEnd
Function MyInstFilesShow
${NSD_CreateLink} 120u 175u 100% 10u "Download manually"
Pop $hCtl_test_Link1
${NSD_OnClick} $hCtl_test_Link1 fnLinkClicked
FunctionEnd
您不能在 NSDialogs 对话框外使用 NSDialogs 控件 (${NSD_Create*}
)!
您可以使用 ChangeUI
/MUI_UI
to add controls to a built-in page or you can add the dynamically at run-time by manually creating a window. You need to use the ButtonEvent plug-in 来捕捉点击事件:
!include "MUI2.nsh"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyInstFilesShow
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!include nsDialogs.nsh ; For style defines
ShowInstDetails hide
Function MyInstFilesShow
FindWindow [=10=] "#32770" "" $HWNDPARENT ; Find the inner dialog
System::Call 'USER32::CreateWindowEx(i0, t "STATIC", t "Download manually", i${WS_CHILD}|${WS_VISIBLE}|${SS_NOTIFY}, i 100, i 200, i 300, i 50, p [=10=], i 0x666, p 0, p 0)p.s'
Pop [=10=]
SetCtlColors [=10=] 0000ff transparent
SendMessage $hwndparent ${WM_GETFONT} 0 0
SendMessage [=10=] ${WM_SETFONT} 1
GetFunctionAddress fnLinkClicked
ButtonEvent::AddEventHandler 0x666
FunctionEnd
Function fnLinkClicked
ExecShell "open" "http://speedtest.ftp.otenet.gr/files/test100Mb.db"
FunctionEnd
我正在尝试创建一个也有 "Download manually" link 的下载器,但 link 似乎没有显示。
我尝试按照 this post 的说明进行操作,但似乎无法正常工作。
我将脚本复制到这里,以防有人指出我可能遗漏的内容 - 抱歉,我是 NSIS 脚本的菜鸟。
!include "MUI2.nsh"
!define NAME "instfileslink"
Name "${NAME}"
OutFile "${NAME}.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyInstFilesShow
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Var hCtl_test_Link1
Section
Section
inetc::get /caption "Downloading package" "http://speedtest.ftp.otenet.gr/files/test100Mb.db" "test100Mb.db" /end
Pop $R0
StrCmp $R0 "OK" 0 dlfailed
Quit
dlfailed:
DetailPrint "Download failed: $R0"
Abort
SectionEnd
Function fnLinkClicked
ExecShell "open" "http://speedtest.ftp.otenet.gr/files/test100Mb.db"
FunctionEnd
Function MyInstFilesShow
${NSD_CreateLink} 120u 175u 100% 10u "Download manually"
Pop $hCtl_test_Link1
${NSD_OnClick} $hCtl_test_Link1 fnLinkClicked
FunctionEnd
您不能在 NSDialogs 对话框外使用 NSDialogs 控件 (${NSD_Create*}
)!
您可以使用 ChangeUI
/MUI_UI
to add controls to a built-in page or you can add the dynamically at run-time by manually creating a window. You need to use the ButtonEvent plug-in 来捕捉点击事件:
!include "MUI2.nsh"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyInstFilesShow
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!include nsDialogs.nsh ; For style defines
ShowInstDetails hide
Function MyInstFilesShow
FindWindow [=10=] "#32770" "" $HWNDPARENT ; Find the inner dialog
System::Call 'USER32::CreateWindowEx(i0, t "STATIC", t "Download manually", i${WS_CHILD}|${WS_VISIBLE}|${SS_NOTIFY}, i 100, i 200, i 300, i 50, p [=10=], i 0x666, p 0, p 0)p.s'
Pop [=10=]
SetCtlColors [=10=] 0000ff transparent
SendMessage $hwndparent ${WM_GETFONT} 0 0
SendMessage [=10=] ${WM_SETFONT} 1
GetFunctionAddress fnLinkClicked
ButtonEvent::AddEventHandler 0x666
FunctionEnd
Function fnLinkClicked
ExecShell "open" "http://speedtest.ftp.otenet.gr/files/test100Mb.db"
FunctionEnd