[英]NSIS : How to keep input value from previous dialog after click Next/Back button?
If I change value in textbox and click Next button, then click Back button to back to the page again, I wanna keep new value that I changed it in textbox. 如果我在文本框中更改了值并单击“下一步”按钮,然后单击“返回”按钮再次返回到页面,则我想保留在文本框中更改了的新值。 How can I do?
我能怎么做?
This is my code : 这是我的代码:
!macro create_AcustomPage APP_NAME CUS_FULLNAME
Page custom create_AcustomPage leave_AcustomPage
Function create_AcustomPage
Push $0
StrCpy $AcustomPage.FirstOpened 0
nsDialogs::Create 1018
Pop $AcustomPage
GetDlgItem $AcustomPage.Button.Next $HWNDPARENT 1
System::Call user32::GetWindowText(i$AcustomPage.Button.Next,t.s,i${NSIS_MAX_STRLEN})
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0u 0u 100% 20u "${AcustomPage_TITLE}"
Pop $AcustomPage.Text
${NSD_CreateGroupBox} 0u 20u 100% 78% "AcustomPage Setting"
Pop $AcustomPage.SettingBox
${NSD_CreateLabel} 10u 50u 20u 11u "URL:"
Pop $AcustomPage.FULLNAME.Label
${NSD_CreateText} 60u 50u 60% 11u ""
Pop $0
${NSD_OnChange} $0 Update_AcustomPage_Next_Button
${If} ${CUS_FULLNAME} != ""
${NSD_SetText} $0 ${CUS_FULLNAME}
${EndIf}
Call Update_AcustomPage_Next_Button
nsDialogs::Show
FunctionEnd
Function leave_AcustomPage
${NSD_GetText} $0 $CUS_FULLNAME
FunctionEnd
Function Update_AcustomPage_Next_Button
Push $R5
${NSD_GetText} $0 $R5
${If} $R5 != ""
EnableWindow $AcustomPage.Button.Next 1
Return
${EndIf}
${If} $R5 == ""
EnableWindow $AcustomPage.Button.Next 0
Return
${EndIf}
Pop $R5
FunctionEnd
!macroend
Thanks, 谢谢,
You are on the right track by always saving the text in $CUS_FULLNAME in the leave callback but you never use $CUS_FULLNAME to set the text when creating the page, you seem to try to do something with ${CUS_FULLNAME} instead! 通过始终将文本保存在请假回调中的$ CUS_FULLNAME中,您将走上正确的轨道,但是在创建页面时从未使用$ CUS_FULLNAME设置文本,而是似乎尝试使用$ {CUS_FULLNAME}来做些事情!
It should probably look more like this: 它可能看起来应该像这样:
${NSD_CreateText} 60u 50u 60% 11u "${CUS_FULLNAME}"
Pop $0
${If} $CUS_FULLNAME != ""
${NSD_SetText} $0 $CUS_FULLNAME
${EndIf}
${NSD_OnChange} $0 Update_AcustomPage_Next_Button
Here is a standalone example: 这是一个独立的示例:
!include nsDialogs.nsh
var hCtlFullName
var FullName
Function mypageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateText} 60u 30u 60% 11u "$FullName"
Pop $hCtlFullName
${NSD_OnChange} $hCtlFullName mypage_VerifyInput
call mypage_VerifyInput
nsDialogs::Show
FunctionEnd
Function mypageLeave
${NSD_GetText} $hCtlFullName $FullName
FunctionEnd
Function mypage_VerifyInput
Call mypageLeave ; Loads the text into $FullName
Push $0
GetDlgItem $0 $HWNDPARENT 1
${If} $FullName == ""
EnableWindow $0 0
${Else}
EnableWindow $0 1
${EndIf}
Pop $0
FunctionEnd
Page Custom mypageCreate mypageLeave
Page Components
Page InstFiles
Section
DetailPrint $FullName
SectionEnd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.