在自定义许可页面加载嵌入文件的内容到RichEdit控件中
Load the content of the embedded file into RichEdit control on the custom license page
要求/用例:
我需要在 NSIS 中实现自定义许可页面。该页面应如下所示:。
在页面上我有 RichEdit 控件,它 显示 eula.rtf 文件的内容。此文件在编译时可用,我无法将其与安装程序分开分发,因此必须以某种方式将其嵌入其中。
目前我正在使用 NSIS 2.46 和 MUI2。下面是我创建 RichEdit 控件的方法:
nsDialogs::CreateControl /NOUNLOAD "RichEdit20A" ${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 1.32u 56.62u 295.54u 63.38u ""
Pop $hCtl_test_rtLicense
问题描述:
我知道默认的 MUI2 许可页面使用 LicenseData and/or LicenseLangString。据我所知,在这种情况下,.rtf 文件嵌入到安装程序中。不幸的是,我不知道如何将嵌入式 .rtf 文件中的内容加载到我的 RichEdit 控件中,即使我查看了 NUI2 附带的 License.nsh 和 NSIS 源代码还有代码。
不幸的是我找到的插件和脚本(LoadRtf plugin, NsRichEdit plugin, this script和一两个)只能将.rtf文件加载到RichEdit控件中运行时.
问题:
如何将嵌入的.rtf文件中的内容加载到自定义页面的RichEdit中?
如果不可能,还有其他方法可以实现我的要求吗?
我唯一能想到的就是将我当前的安装程序包装到另一个精简的 NSIS 安装程序中,该安装程序将与当前安装程序一起静默部署 .rtf 文件。这感觉很乱,所以我宁愿不这样做..
唯一的方法是在 运行 时间。要使用您链接到的解决方案之一,您只需提取 .rtf 文件并调用插件:
InitPluginsDir ; Initialize $PluginsDir, it is deleted automatically when installer quits
File "/oname=$PluginsDir\lic.rtf" "MyLicense.rtf"
# Call plugin here passing in "$PluginsDir\lic.rtf" as the file to load
或者如果您不想使用第 3 方插件:
Page Custom MyPage
Page InstFiles
!include LogicLib.nsh
!include nsDialogs.nsh
!define SF_RTF 2
!define EM_STREAMIN 1097
Function LoadRichRtf
System::Store S
Pop [=11=] ; hwnd
Pop ; path to rtf
FileOpen r
System::Get "(i, i .R0, i .R1, i .R2)iss"
Pop
System::Call "*(*i 0, i 0, k r2)i.r3"
System::Call "USER32::SendMessage(ir0, i${EM_STREAMIN}, i${SF_RTF}, ir3)i.s"
loop:
Pop [=11=]
StrCmp [=11=] "callback1" 0 done
System::Call 'KERNEL32::ReadFile(ir1, iR0, iR1, iR2, i0)'
Push 0 # callback's return value
System::Call ""
Goto loop
done:
System::Free
System::Free
FileClose
System::Store L
FunctionEnd
Var hCtl_test_rtLicense
Function MyPage
nsDialogs::Create 1018
Pop [=11=]
nsDialogs::CreateControl /NOUNLOAD "RichEdit20A" ${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 1.32u 56.62u 295.54u 63.38u ""
Pop $hCtl_test_rtLicense
File "/oname=$PluginsDir\lic.rtf" "c:\some\local\path\License_en_US.rtf"
Push "$PluginsDir\lic.rtf"
Push $hCtl_test_rtLicense
Call LoadRichRtf
nsDialogs::Show
FunctionEnd
要求/用例:
我需要在 NSIS 中实现自定义许可页面。该页面应如下所示:
在页面上我有 RichEdit 控件,它 显示 eula.rtf 文件的内容。此文件在编译时可用,我无法将其与安装程序分开分发,因此必须以某种方式将其嵌入其中。
目前我正在使用 NSIS 2.46 和 MUI2。下面是我创建 RichEdit 控件的方法:
nsDialogs::CreateControl /NOUNLOAD "RichEdit20A" ${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 1.32u 56.62u 295.54u 63.38u ""
Pop $hCtl_test_rtLicense
问题描述:
我知道默认的 MUI2 许可页面使用 LicenseData and/or LicenseLangString。据我所知,在这种情况下,.rtf 文件嵌入到安装程序中。不幸的是,我不知道如何将嵌入式 .rtf 文件中的内容加载到我的 RichEdit 控件中,即使我查看了 NUI2 附带的 License.nsh 和 NSIS 源代码还有代码。
不幸的是我找到的插件和脚本(LoadRtf plugin, NsRichEdit plugin, this script和一两个)只能将.rtf文件加载到RichEdit控件中运行时.
问题:
如何将嵌入的.rtf文件中的内容加载到自定义页面的RichEdit中?
如果不可能,还有其他方法可以实现我的要求吗?
我唯一能想到的就是将我当前的安装程序包装到另一个精简的 NSIS 安装程序中,该安装程序将与当前安装程序一起静默部署 .rtf 文件。这感觉很乱,所以我宁愿不这样做..
唯一的方法是在 运行 时间。要使用您链接到的解决方案之一,您只需提取 .rtf 文件并调用插件:
InitPluginsDir ; Initialize $PluginsDir, it is deleted automatically when installer quits
File "/oname=$PluginsDir\lic.rtf" "MyLicense.rtf"
# Call plugin here passing in "$PluginsDir\lic.rtf" as the file to load
或者如果您不想使用第 3 方插件:
Page Custom MyPage
Page InstFiles
!include LogicLib.nsh
!include nsDialogs.nsh
!define SF_RTF 2
!define EM_STREAMIN 1097
Function LoadRichRtf
System::Store S
Pop [=11=] ; hwnd
Pop ; path to rtf
FileOpen r
System::Get "(i, i .R0, i .R1, i .R2)iss"
Pop
System::Call "*(*i 0, i 0, k r2)i.r3"
System::Call "USER32::SendMessage(ir0, i${EM_STREAMIN}, i${SF_RTF}, ir3)i.s"
loop:
Pop [=11=]
StrCmp [=11=] "callback1" 0 done
System::Call 'KERNEL32::ReadFile(ir1, iR0, iR1, iR2, i0)'
Push 0 # callback's return value
System::Call ""
Goto loop
done:
System::Free
System::Free
FileClose
System::Store L
FunctionEnd
Var hCtl_test_rtLicense
Function MyPage
nsDialogs::Create 1018
Pop [=11=]
nsDialogs::CreateControl /NOUNLOAD "RichEdit20A" ${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 1.32u 56.62u 295.54u 63.38u ""
Pop $hCtl_test_rtLicense
File "/oname=$PluginsDir\lic.rtf" "c:\some\local\path\License_en_US.rtf"
Push "$PluginsDir\lic.rtf"
Push $hCtl_test_rtLicense
Call LoadRichRtf
nsDialogs::Show
FunctionEnd