将超链接实现到 LangString
Implement a Hyperlink into an LangString
实际上我正在尝试使用 NSIS 标准库将超链接实现到我的 LangString 中。但是当我 "only" 将 Link 写入 LangString 时,它无法点击。
我正在使用自己的 .nsh 构建 LangStrings:
!undef LANG
!define LANG = "English"
!LANG_STRING "myTest" "search on google: https://google.com/"
在我的 nsis Main 中,代码片段看起来像:
!macro LANG_STRING NAME VALUE
LangString "${NAME}" "${LANG_${LANG}}" "${VALUE}"
!macroend
!macro LANG_LOAD lang
!insertmacro MUI_LANGUAGE "${lang}"
!verbose 1
!include "descriptions${lang}.nsh"
!verbose 4
!undef LANG
!macroend
#Pages(here i build my pages up)
!insertmacro LANG_LOAD "English"
是否有我可以实现的处理方式,如果是,我必须在哪里实现它。
没有对此的内置支持。 NSIS 不会尝试检测字符串中的 URLs 并且 Windows 控件在旧版本(XP 之前)中相当有限。
您可以使用 RichEdit 控件伪造它,但没有内置 WM_NOTIFY 处理程序来启动 URL:
System::Call 'KERNEL32::LoadLibrary(t "MsftEdit")' ; 4.1+, Windows XP SP1 and later
FindWindow "#32770" "" $HWNDPARENT
SendMessage ${WM_GETFONT} 0 0
System::Call 'USER32::CreateWindowExW(i ${WS_EX_TRANSPARENT}, w "RICHEDIT50W", p0, i ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_MULTILINE}|${ES_READONLY}, i 0, i 0, i 300, i 50, p , p 0, p 0, p 0)p.s'
Pop
SendMessage ${WM_SETFONT} 1
!define /math EM_SETTEXTEX ${WM_USER} + 97
System::Call "USER32::SendMessage(p,i${EM_SETTEXTEX},*l0,ts)" '{\rtf1{Hello} {\field{\*\fldinst{HYPERLINK "https://whosebug.com/questions/tagged/nsis"}}{\fldrslt{SO link}}} {World}}'
可以在 nsDialogs 页面上处理 WM_NOTIFY。在内置页面上,您需要一个自定义插件。您也许可以问 NSIS v3 中 ButtonEvent plug-in to add support for this message. If < XP SP1 support is needed you would have to use a older version of the RichEdit control and the EM_AUTOURLDETECT message instead, this means the URL must be visible in the text. The nsDialogs example 的作者是否这样做。
另一种选择是 SysLink control 但它也有同样的 WM_NOTIFY 问题并且也仅限于 Windows XP 和更高版本的 ComCtlv6 (XPStyle On
) 并且是仅限 Unicode。 Windows 2000 上存在不同的内部实现,但我不确定它是否已记录在案。
最后的选择是Linker plug-in。我自己从来没有尝试过,如果你想混合链接和普通文本,你必须创建几个标签。
实际上我正在尝试使用 NSIS 标准库将超链接实现到我的 LangString 中。但是当我 "only" 将 Link 写入 LangString 时,它无法点击。
我正在使用自己的 .nsh 构建 LangStrings:
!undef LANG
!define LANG = "English"
!LANG_STRING "myTest" "search on google: https://google.com/"
在我的 nsis Main 中,代码片段看起来像:
!macro LANG_STRING NAME VALUE
LangString "${NAME}" "${LANG_${LANG}}" "${VALUE}"
!macroend
!macro LANG_LOAD lang
!insertmacro MUI_LANGUAGE "${lang}"
!verbose 1
!include "descriptions${lang}.nsh"
!verbose 4
!undef LANG
!macroend
#Pages(here i build my pages up)
!insertmacro LANG_LOAD "English"
是否有我可以实现的处理方式,如果是,我必须在哪里实现它。
没有对此的内置支持。 NSIS 不会尝试检测字符串中的 URLs 并且 Windows 控件在旧版本(XP 之前)中相当有限。
您可以使用 RichEdit 控件伪造它,但没有内置 WM_NOTIFY 处理程序来启动 URL:
System::Call 'KERNEL32::LoadLibrary(t "MsftEdit")' ; 4.1+, Windows XP SP1 and later
FindWindow "#32770" "" $HWNDPARENT
SendMessage ${WM_GETFONT} 0 0
System::Call 'USER32::CreateWindowExW(i ${WS_EX_TRANSPARENT}, w "RICHEDIT50W", p0, i ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_MULTILINE}|${ES_READONLY}, i 0, i 0, i 300, i 50, p , p 0, p 0, p 0)p.s'
Pop
SendMessage ${WM_SETFONT} 1
!define /math EM_SETTEXTEX ${WM_USER} + 97
System::Call "USER32::SendMessage(p,i${EM_SETTEXTEX},*l0,ts)" '{\rtf1{Hello} {\field{\*\fldinst{HYPERLINK "https://whosebug.com/questions/tagged/nsis"}}{\fldrslt{SO link}}} {World}}'
可以在 nsDialogs 页面上处理 WM_NOTIFY。在内置页面上,您需要一个自定义插件。您也许可以问 NSIS v3 中 ButtonEvent plug-in to add support for this message. If < XP SP1 support is needed you would have to use a older version of the RichEdit control and the EM_AUTOURLDETECT message instead, this means the URL must be visible in the text. The nsDialogs example 的作者是否这样做。
另一种选择是 SysLink control 但它也有同样的 WM_NOTIFY 问题并且也仅限于 Windows XP 和更高版本的 ComCtlv6 (XPStyle On
) 并且是仅限 Unicode。 Windows 2000 上存在不同的内部实现,但我不确定它是否已记录在案。
最后的选择是Linker plug-in。我自己从来没有尝试过,如果你想混合链接和普通文本,你必须创建几个标签。