按上一步返回自定义页面后原控件置灰失效问题

优质
小牛编辑
136浏览
2023-12-01
问: 自定义的页面在创建函数置灰了控件,但是进行到下个页面,再按上一步,返回到自定义的页面时,发现置灰已经失效了,了解到可能创建函数只执行一次的结果。想问一下,有什么方法解决这个问题,下面是这一部份的源码:

UninstPage custom un.nsDialogsChoicePage un.nsDialogsChoicePageLeave
Var ServerStat
Var ClientStat
Var CheckboxServer
Var CheckboxServer_State

Var CheckboxClient
Var CheckboxClient_State
Function un.nsDialogsChoicePage
        nsDialogs::Create /NOUNLOAD 1018
        Pop $Dialog

        ${If} $Dialog == error
                Abort
        ${EndIf}

        ${NSD_CreateCheckbox} 0 30u 100% 10u "XX"
        Pop $CheckboxServer

        ${NSD_CreateCheckbox} 0 60u 100% 10u "XX"
        Pop $CheckboxClient

        ServerStat="yes"
        ${If} $ServerStat != "yes"
            FindWindow $0 "#32770" "" $HWNDPARENT
                  GetDlgItem $0 $0 1201  
                         EnableWindow $0 0
        ${EndIf}
        
        ClientStat=""
        ${If} $ClientStat != "yes"
            FindWindow $0 "#32770" "" $HWNDPARENT
                  GetDlgItem $0 $0 1202   
                         EnableWindow $0 0
        ${EndIf}

        ${If} $CheckboxServer_State == ${BST_CHECKED}
                ${NSD_Check} $CheckboxServer
        ${EndIf}

        ${If} $CheckboxClient_State == ${BST_CHECKED}
                ${NSD_Check} $CheckboxClient
        ${EndIf}
        nsDialogs::Show

FunctionEnd

Function un.nsDialogsChoicePageLeave1
        ${NSD_GetState} $CheckboxClient $CheckboxClient_State
        ${NSD_GetState} $CheckboxServer $Checkboxserver_State
FunctionEnd

答:修改下面两段
1、
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1201
EnableWindow $0 0

修改为:
EnableWindow $CheckboxServer 0

2、
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1202
EnableWindow $0 0

修改为:
EnableWindow $CheckboxClient 0

在$CheckboxServer $CheckboxClient这两个变量中,分别保存的就是${NSD_CreateCheckbox}创建的那两个Checkbox控件的句柄,所以直接设置控件状态即可。