NSIS:单击 Next/Back 按钮后如何保留上一个对话框的输入值?

NSIS : How to keep input value from previous dialog after click Next/Back button?

如果我更改文本框中的值并单击下一步按钮,然后单击返回按钮再次返回页面,我想保留我在文本框中更改的新值。我该怎么办?

这是我的代码:

AcustomPage.nsh

!macro create_AcustomPage APP_NAME CUS_FULLNAME
Page custom create_AcustomPage leave_AcustomPage
Function create_AcustomPage
        Push [=11=]
        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 [=11=]
        ${NSD_OnChange} [=11=] Update_AcustomPage_Next_Button
        ${If} ${CUS_FULLNAME} != ""
            ${NSD_SetText} [=11=] ${CUS_FULLNAME}
        ${EndIf}
            
        Call Update_AcustomPage_Next_Button
        nsDialogs::Show
    FunctionEnd
    
    Function leave_AcustomPage
        ${NSD_GetText} [=11=] $CUS_FULLNAME
    FunctionEnd
    
    Function Update_AcustomPage_Next_Button
    Push $R5
        ${NSD_GetText} [=11=] $R5
        ${If} $R5 != ""
                    EnableWindow $AcustomPage.Button.Next 1
                    Return
        ${EndIf}
        ${If} $R5 == ""
            EnableWindow $AcustomPage.Button.Next 0
            Return
        ${EndIf}
    Pop $R5
    FunctionEnd
!macroend

谢谢,

你总是在离开回调中将文本保存在 $CUS_FULLNAME 中,但你在创建页面时从未使用 $CUS_FULLNAME 设置文本,你似乎在尝试用 ${CUS_FULLNAME} 代替!

它应该看起来更像这样:

${NSD_CreateText} 60u 50u 60% 11u "${CUS_FULLNAME}"
Pop [=10=]
${If} $CUS_FULLNAME != ""
  ${NSD_SetText} [=10=] $CUS_FULLNAME
${EndIf}
${NSD_OnChange} [=10=] Update_AcustomPage_Next_Button

这是一个独立的例子:

!include nsDialogs.nsh

var hCtlFullName
var FullName

Function mypageCreate
nsDialogs::Create 1018
Pop [=11=]

${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 [=11=]
GetDlgItem [=11=] $HWNDPARENT 1
${If} $FullName == ""
    EnableWindow [=11=] 0
${Else}
    EnableWindow [=11=] 1
${EndIf}
Pop [=11=]
FunctionEnd

Page Custom mypageCreate mypageLeave
Page Components
Page InstFiles

Section
DetailPrint $FullName
SectionEnd