【问题标题】:Added link to MUI_PAGE_INSTFILES does not show添加到 MUI_PAGE_INSTFILES 的链接不显示
【发布时间】:2017-10-16 16:20:31
【问题描述】:

我正在尝试创建一个也具有“手动下载”链接的下载器,但该链接似乎没有显示。

我尝试按照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

【问题讨论】:

标签: nsis


【解决方案1】:

您不能在 NSDialogs 对话框之外使用 NSDialogs 控件 (${NSD_Create*})!

您可以使用ChangeUI/MUI_UI 将控件添加到内置页面,也可以通过手动创建窗口在运行时动态添加。您需要使用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 $0 "#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 $0, i 0x666, p 0, p 0)p.s'
  Pop $0
  SetCtlColors $0 0000ff transparent 
  SendMessage $hwndparent ${WM_GETFONT} 0 0 $1
  SendMessage $0 ${WM_SETFONT} $1 1
  GetFunctionAddress $1 fnLinkClicked
  ButtonEvent::AddEventHandler 0x666 $1
FunctionEnd

Function fnLinkClicked
  ExecShell "open" "http://speedtest.ftp.otenet.gr/files/test100Mb.db"
FunctionEnd

【讨论】:

  • 如何通过ChangeUI实现? IMO,最好这样做,这样可以保留 MUI2“主题”。例如,我在 Finish.nsh !ifdef MUI_FINISHPAGE_LINK ${NSD_CreateLink} 120u 175u 195u 10u "${MUI_FINISHPAGE_LINK}" Pop $mui.FinishPage.Link SetCtlColors $mui.FinishPage.Link "${MUI_FINISHPAGE_LINK_COLOR}" "${MUI_BGCOLOR}" ${NSD_OnClick} $mui.FinishPage.Link "${LINK}" !endif 中看到了这个块
  • 完成页面是自定义页面,不是内置页面,因此无法使用ChangeUI进行更改。
  • 我正在尝试将其与Linker plugin 结合起来以包含链接的下划线样式,但它不起作用。或者修改 $1 中的字体可能更容易(只是不知道具体是怎么做的)?
猜你喜欢
  • 2013-11-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-30
  • 2016-08-22
  • 1970-01-01
相关资源
最近更新 更多