NSIS 自定义页面 MessageBox 跳转到下一页

NSIS Custom Page MessageBox jump to next page

页面自定义模式PageCreate模式PageLeave

Function ModePageLeave
    MessageBox MB_YESNO "Installer is now going to uninstall existing software and reinstall software. Database files will be removed. Please confirm to proceed!" IDYES true IDNO false
        true:
        call silentUninst

        false:
        System::Call 'USER32::PostMessage(i$HWNDPARENT,i0x408,i-1,i0)'
        #Abort
FunctionEnd

我有一个自定义页面,在此我想在用户单击下一步(自定义页面的下一步)时显示一个消息框

现在点击下一个消息框,并接受用户的确认。然后,如果用户单击“是”,它应该转到下一页,如果“否”,则它应该停留在同一自定义页面上。

使用此代码,无论单击“是”还是“否”,我都会获得相同的自定义页面。每次我都只使用自定义页面。

来自文档:

The leave-function allows you to force the user to stay on the current page using Abort.

您的代码始终执行 false: 部分。

您可以将其更改为

Function ModePageLeave
    MessageBox MB_YESNO "Something?" IDYES true IDNO false
        true:
        call silentUninst
        goto done

        false:
        System::Call 'USER32::PostMessage(i$HWNDPARENT,i0x408,i-1,i0)'
        done:
FunctionEnd

但是用官方的方法会好很多:

Page Components
Page Custom myPageCreate myPageLeave
Page Directory
Page Instfiles

Function myPageCreate
nsDialogs::Create 1018
Pop [=11=]
nsDialogs::Show
FunctionEnd

Function myPageLeave
MessageBox MB_YESNO "Something?" IDYES goNext
  Abort ; Stay on page
goNext:
FunctionEnd
Function ModePageLeave
    MessageBox MB_YESNO "Installer is now going to uninstall existing software and reinstall software. Database files will be removed. Please confirm to proceed!" IDYES true IDNO false
        true:
        call silentUninst
        abort

        false:
        System::Call 'USER32::PostMessage(i$HWNDPARENT,i0x408,i-1,i0)'
        #Abort
FunctionEnd