如何在NSIS中启用禁用的下一步按钮?

时间:2013-10-17 06:16:56

标签: nsis

在我的自定义页面中,我在页面加载时禁用了下一个按钮...因为有一些后台进程需要完成,直到我们不能进入下一页。所以我使用以下代码禁用了下一个按钮。

GetDlgItem $1 $HWNDPARENT 1 
EnableWindow $1 0

但是我想在后台进程完成后启用下一个按钮。我已经使用了以下代码来启用

GetDlgItem $1 $HWNDPARENT 1 
EnableWindow $1 1

但它没有用......请你告诉我这个错误或者在NSIS中如何做到这一点?

以下是我的代码

Function StartProgressPage
    ; Set dialog text:
    !insertmacro MUI_HEADER_TEXT "$(STARTPRGDIA_TITLE)" "$(STARTPRGDIA_SUBTITLE)"

    ; Display the page:
    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "StartPrgDia"

    ;Disable Next Button
    GetDlgItem $0 $HWNDPARENT 1
    EnableWindow $0 0

    nsDialogs::Create 1018
    Pop $dialog
    nsDialogs::CreateControl "msctls_progress32" \
        ${DEFAULT_STYLES}|${PBS_SMOOTH} \
        ${PB_EXSTYLE} \
        0 30 100% 10% \
        "Test" \

    Pop $hwnd
    ${NSD_CreateTimer} NSD_Timer.CallStop 10
    nsDialogs::Show
FunctionEnd

Function NSD_Timer.CallStop
    ${NSD_KillTimer} NSD_Timer.CallStop ; Kill the timer
    SendMessage $hwnd ${PBM_SETRANGE32} 0 100

    SendMessage $hwnd ${PBM_SETPOS} 25 0
    Call <Some Process>
    SendMessage $hwnd ${PBM_SETPOS} 50 0
    Call ConfPropertyChanges
    SendMessage $hwnd ${PBM_SETPOS} 100 0
    ${NSD_CreateLabel} 0 10 20% 10u Completed

    ;Enable Next Button
    GetDlgItem $0 $HWNDPARENT 1
    EnableWindow $0 1
FunctionEnd

1 个答案:

答案 0 :(得分:0)

据我所知,安装程序会在此代码中等待:

!insertmacro MUI_INSTALLOPTIONS_DISPLAY "StartPrgDia"

直到用户转到下一页。 你确定在显示自定义页面时执行此行后的代码吗?

你应该致电

!insertmacro MUI_INSTALLOPTIONS_DISPLAY "StartPrgDia"

在你的所有代码之后或使用它(MUI2版本)

Function CustomPage
    !insertmacro INSTALLOPTIONS_INITDIALOG "page.ini"

    # your code here

    !insertmacro INSTALLOPTIONS_SHOW

FunctionEnd