如何从两个不同的任务控制进度条

时间:2012-10-23 01:11:11

标签: nsis

我有一个自定义页面,并添加了一个进度条。现在我有两个函数来控制进度条。一个功能是停止少量服务,另一个功能是从安装位置备份一些文件。

Function myCustomPage
    Var /GLOBAL progressBar
    Var /GLOBAL label 
    !insertmacro MUI_HEADER_TEXT "Setup is preaparing to install updates" "Please wait"
    nsDialogs::Create 1018 
    ${NSD_CreateLabel} 10 15 80% 10% ""
    Pop $label
    ${NSD_CreateProgressBar} 10 30 80% 8% ""
    Pop $progressBar

    ${NSD_CreateTimer} BackUp_Files.Callback 10
    ${NSD_CreateTimer} Stop_Services.Callback 10 
    nsDialogs::Show
FunctionEnd

Stop_Services回调函数

Function Stop_Services.Callback
    ${NSD_SetText} $label "Stopping services"
    ${NSD_KillTimer} Stop_Services.Callback
    SendMessage $progressBar ${PBM_SETRANGE32} 0 100 
    SendMessage $progressBar ${PBM_SETPOS} 25 0
    Sleep 100
    SendMessage $progressBar ${PBM_SETPOS} 25 0 
    Sleep 100
    SendMessage $progressBar ${PBM_SETPOS} 50 0 
    Sleep 100
    SendMessage $progressBar ${PBM_SETPOS} 75 0 
    Sleep 100
    SendMessage $progressBar ${PBM_SETPOS} 100 0
FuncionEnd

Backup_files.callback具有相同类型的结构。 结果:  当我看到标签时,它在“停止服务”和“备份文件”之间进行切换。 任何人都可以告诉我如何处理这个问题。我想先停止服务,然后我想复制备份文件。停止服务后,需要将进度条设置为0,然后再次启动以备份文件。我需要在单个自定义页面上执行此操作。

1 个答案:

答案 0 :(得分:1)

只需使用一个计时器,并在第一个任务call的末尾直接使用第二个任务函数......

相关问题