[英]Remember check box state when click back during NSIS installer
I have a checkbox on one of my customer installer pages 我的客户安装程序页面之一上有一个复选框
${NSD_CreateCheckbox} 0 0 100% 15 "Check to run"
Pop $SvcCheckBox
CreateFont $0 "$(^Font)" "10"
SendMessage $SvcCheckBox ${WM_SETFONT} $0 1
GetFunctionAddress $0 OnCheckbox
nsDialogs::OnClick $SvcCheckBox $0
I want to remember this if the user comes back to this page. 如果用户返回此页面,我想记住这一点。
I've used the code below to attempt this 我用下面的代码尝试
${NSD_OnBack} "pageLeave"
FunctionEnd
Function pageLeave
${NSD_GetState} $SvcCheckBoxState $SvcCheckBox
FunctionEnd
However, if a user un-checks the box, goes to the next page, comes back to this page, the check box is checked again. 但是,如果用户取消选中该复选框,则转到下一页,然后返回此页面,则再次选中该复选框。 I need it to remain unchecked.
我需要它保持不受检查。
How do I implement my pageLeave check box state on page load? 如何在页面加载时实现pageLeave复选框状态?
You need initialize the checkbox state when you create the page. 创建页面时,需要初始化复选框状态。 You don't need a On* handler unless you want to update something else on the page when the checkbox changes.
您不需要On *处理程序,除非您希望在复选框更改时更新页面上的其他内容。
!include nsDialogs.nsh
Var CheckboxState
Var hCheckbox
Function .onInit
StrCpy $CheckboxState ${BST_CHECKED} ; Set initial/default state
FunctionEnd
Page Components
Page Custom MyPageCreate MyPageLeave
Page Components
Page InstFiles
Function MyPageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateCheckbox} 0 0 100% 15 "Check to run"
Pop $hCheckbox
${NSD_SetState} $hCheckbox $CheckboxState
nsDialogs::Show
FunctionEnd
Function MyPageLeave
${NSD_GetState} $hCheckbox $CheckboxState
FunctionEnd
Section
DetailPrint State=$CheckboxState
SectionEnd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.