清除 InstallOptions 页面中的字段状态
我正在开发 NSIS 安装程序。要求之一是允许用户为多个不同的条目多次输入某些信息(本质上,它允许他们为任意数量的服务器输入服务器信息)。我目前正在通过在高级选项页面之后转到此页面来回收页面:
Function RedirectPage
${If} $addtCheck <> 0 ; Was the checkbox checked?
StrCpy $startedXml 1 ; make this "true"
SendMessage $HWNDPARENT 0x408 -1 "" ; If so, go back
${Else}
Abort
${EndIf}
FunctionEnd
addtCheck
检查是否选中了回收页面的复选框。如果是这样,此函数会导致再次显示上一页。问题在于这些字段包含用户刚刚输入的信息。现在,我想做的是在返回前一页之前清除上一页所有字段的状态。我尝试过做这样的事情,
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioAdv.ini" "Field 2" "State" ""
但它似乎不允许我清除状态。我知道 SendMessage
和 GetDlgItem
命令,但不知道有任何方法允许我使用它们来清除包含在的文本框、复选框和列表框InstallOptions INI 文件。
任何人都可以指出我正确的方向,谢谢。如果您想查看更多脚本,请告诉我。
I'm working on an NSIS installer. One of the requirements is to allow the user to input some information multiple times for multiple different entries (essentially, it allows them to enter server information for as many servers as they'd like). I'm currently recycling the pages by going to this page after my advanced options page:
Function RedirectPage
${If} $addtCheck <> 0 ; Was the checkbox checked?
StrCpy $startedXml 1 ; make this "true"
SendMessage $HWNDPARENT 0x408 -1 "" ; If so, go back
${Else}
Abort
${EndIf}
FunctionEnd
addtCheck
checks to see if the checkbox is ticked that recycles the page. If so this function causes the previous page to be displayed again. The problem is that the fields contain the information that the user just entered. Now, what I want to do is to clear the State of all of the fields of the previous page before they go back to it. I have tried doing something like this,
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioAdv.ini" "Field 2" "State" ""
but it doesn't seem to allow me to clear the state. I know of the SendMessage
and GetDlgItem
commands, but am unaware of any methods that allow me to use them to clear the text boxes, check boxes, and list boxes of contained in the InstallOptions INI file.
Anyone who can point me in the right direction, thanks. If you want to see any more of the script, let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以你应该在 ini 中有这样的控件:
然后你可以像这样获得字段的句柄:
那么你可以像这样使用带有
$0
的SendMessage
命令:此示例应该适用于文本框,对于其他控件,请参见以下内容:
在 NSIS 安装路径的“包含”下,有文件
Winmessages.nsh
以及要使用的消息密钥。在我的测试中,我找到了设置复选框的关键:
对于列表框,我发现:(未经测试)
希望有所帮助。
PS:如果您有任何疑问或批评,请告诉我。
PPS:
或者,您可以将 nsDialogs 宏与 HWND 句柄一起使用,即用于复选框:
有关此宏的更多信息如下:
nsDialogs 自述文件 - 宏
So you should have the controls in the ini like this:
then you can get a handle on the field like this:
So then you can use the
SendMessage
command with$0
like this:This example should work on Text Boxes, for the other controls see the following:
In the NSIS Installation Path under "Include" there is the File
Winmessages.nsh
with the Message Keys to use.In my tests i found the key for setting checkboxes:
For ListBoxes i found: (untested)
Hope that helps.
PS: If you have any questions or critisism, please let me know.
PPS:
Alternatively, you could use the nsDialogs Macros with the HWND handle, i.e. for the Checkbox:
More Information to this Macros are here:
nsDialogs Readme - Macros
您可以使用 SendMessage 重置每个控件,但随后您必须处理不同类型的控件,最好只重置 .ini:
..或重置状态并保留其他所有内容:(
这将重置链接和按钮控件,以便如果需要,将其过滤出循环)
You can use SendMessage to reset each control but then you have to handle different types of controls, it is much better to just reset the .ini:
..or reset the state and keep everything else:
(This will reset link and button controls so filter those out of the loop if required)