动态添加自定义页面(在运行时)

发布于 2024-12-06 05:09:14 字数 302 浏览 1 评论 0原文

我正在使用 NSIS 安装程序脚本语言编写安装脚本。我有一些可以轻松加载的自定义页面,但我想知道是否可以动态插入页面。我想要做的是有一个页面,上面有其他配置选项,底部有一个复选框,上面写着“添加更多设置”或类似的内容。如果选中该复选框,它将显示另一个自定义页面,该页面与第一个页面完全相同。只要用户继续选中该复选框,就应该显示更多页面。有没有某种方法可以一遍又一遍地回收同一页面?我真的不认为我应该需要生成一个全新的页面,因为它只是一次又一次相同的页面,但我不确定如何在运行时显示同一页面的新实例。快速谷歌和 stackoverflow 搜索并不能保证任何结果。

谢谢你们。

I'm writing an install script utilizing the NSIS installer scripting language. I have a few custom pages that I am able to load without hassle, but I was wondering if it would be possible to insert pages dynamically. What I want to do is have a page with additional configuration options on it and on the bottom have a checkbox that says "Add more settings" or something similar. If the checkbox is ticked, it will show another custom page that's an exact copy of the first one. As long as the user keeps checking the checkbox, more pages should be shown. Is there some method of recycling the same page over and over again? I really don't think I should need to generate a whole new page because it's just the same page again and again, but I'm not sure how to show a new instance of the same page during runtime. A quick Google and stackoverflow search did not warrant any results.

Thanks guys.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请叫√我孤独 2024-12-13 05:09:14

页数在编译时是固定的。

如果您需要不同的“隐藏”页面或仅同一页面的几个实例,我想说您应该在页面创建回调中通过调用 abort 来跳过页面,但如果页面计数,这将不起作用是无限的。

也可以直接进入页面:

Outfile test.exe
Requestexecutionlevel user

!include nsDialogs.nsh

Page Custom mypagecreate mypageleave
Page Directory dirpagecreate
Page Instfiles

Function mypagecreate
Var /Global MyCheckBox
nsDialogs::Create /NOUNLOAD 1018
Pop $0
${NSD_CreateCheckBox} 10% 20u 80% 12u "Again?"
Pop $MyCheckBox
nsDialogs::Show
FunctionEnd

Function mypageleave
${NSD_GetState} $MyCheckBox $0
StrCpy $MyCheckBox $0 ; This is a bit of a hack, we reuse the HWND var to store the state
FunctionEnd

Function dirpagecreate
${If} $MyCheckBox <> 0 ; Was the checkbox checked?
    SendMessage $HWNDPARENT 0x408 -1 "" ; If so, go back
${EndIf}
FunctionEnd

Section
SectionEnd

The number of pages is fixed at compile time.

If you need different "hidden" pages or just a couple instances of the same page I would say that you should just skip the pages when required in the create callback for the page by calling abort but this is not going to work if the page count is unlimited.

It is also possible to go directly to a page:

Outfile test.exe
Requestexecutionlevel user

!include nsDialogs.nsh

Page Custom mypagecreate mypageleave
Page Directory dirpagecreate
Page Instfiles

Function mypagecreate
Var /Global MyCheckBox
nsDialogs::Create /NOUNLOAD 1018
Pop $0
${NSD_CreateCheckBox} 10% 20u 80% 12u "Again?"
Pop $MyCheckBox
nsDialogs::Show
FunctionEnd

Function mypageleave
${NSD_GetState} $MyCheckBox $0
StrCpy $MyCheckBox $0 ; This is a bit of a hack, we reuse the HWND var to store the state
FunctionEnd

Function dirpagecreate
${If} $MyCheckBox <> 0 ; Was the checkbox checked?
    SendMessage $HWNDPARENT 0x408 -1 "" ; If so, go back
${EndIf}
FunctionEnd

Section
SectionEnd
初心 2024-12-13 05:09:14
page custom page1 option
page instfiles

Function page1
initpluginsdir
file /oname=$PLUGINSDIR\dlg.ini dlg.ini
installoptions::dialog "$PLUGINSDIR\dlg.ini"
FunctionEnd

Function Options
ReadINIStr $0 "$PLUGINSDIR\dlg.ini" "Field 1" "State" # Field Must have value 0 or 1. Maybe Text or Chechbox
StrCmp $0 0 0 +2
abort
FunctionEnd
page custom page1 option
page instfiles

Function page1
initpluginsdir
file /oname=$PLUGINSDIR\dlg.ini dlg.ini
installoptions::dialog "$PLUGINSDIR\dlg.ini"
FunctionEnd

Function Options
ReadINIStr $0 "$PLUGINSDIR\dlg.ini" "Field 1" "State" # Field Must have value 0 or 1. Maybe Text or Chechbox
StrCmp $0 0 0 +2
abort
FunctionEnd
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文